表单提交验证

时间:2022-11-06 17:07:47
<div class="fix-form">
<div>
<form id="sendform" name="sendform" method="post">
<input id="post_url" type="hidden" name="url" value="https://">
<input type="hidden" name="orgid" value="00D90000000lh7N">
<input type="hidden" name="retURL" value="http://">
<input type="hidden" name="recordType" id="recordType" value="0126F0000012HjF" />
<div class="container">
<div class="row">
<div class="col-md-8 title">title</div>
<div class="col-xs-12 text-center show-form">
<span class="fa fa-angle-down"></span>
</div>
</div>
<div class="row">
<div class="col-md-8 col-sm-12 left">
<div class="col-md-6">
姓名
<input id="00N90000008PMXk" maxlength="80" name="00N90000008PMXk" size="20" type="text" />*必填
</div>
<div class="col-md-6">
手机
<input id="00N90000008PMXl" maxlength="40" name="00N90000008PMXl" size="20" type="text" />*必填
</div>
<div class="col-md-6">
邮箱
<input id="00N90000008PMXj" maxlength="80" name="00N90000008PMXj" size="20" type="text" />*必填
</div>
<input type="hidden" name="subject" value="Juwai Summit - Beijing - 2018" />
<input style="display:none" id="00N90000006GMET" value="693735" maxlength="20" name="00N90000006GMET" size="20" type="text" />
<input type="hidden" name="00N90000006IK3a" id="00N90000006IK3a" maxlength="20" size="20" type="text" />
<input style="display:none" id="00N6F00000E1zXD" maxlength="255" name="00N6F00000E1zXD" size="20" type="text" />
<input style="display:none" id="00N90000009SB6L" maxlength="255" name="00N90000009SB6L" size="20" type="text" />
<input style="display:none" id="00N90000009SBCo" maxlength="255" name="00N90000009SBCo" size="20" type="text" />
<input style="display:none" id="00N90000009SB6G" maxlength="255" name="00N90000009SB6G" size="20" type="text" />
<input style="display:none" id="00N6F00000E1zN8" maxlength="255" name="00N6F00000E1zN8" size="20" type="text" />
<input style="display:none" id="00N6F00000EgmtT" name="00N6F00000EgmtT" type="checkbox" value="1" />
<input style="display:none" id="00N6F00000EgmtY" name="00N6F00000EgmtY" type="checkbox" value="1" />
<input style="display:none" id="00N6F00000Egmtd" maxlength="50" name="00N6F00000Egmtd" size="20" type="text" />
<input type="hidden" name="00N6F00000EgUQc" id="00N6F00000EgUQc" value="Landing Page" />
<div class="col-md-6 buttons">
<button type="button" onclick="gotoSend()">确定</button>
</div>
</div>
<div class="col-md-4 col-sm-12 right">
<h5 class="first hidden-xs hidden-sm">section</h5>
<h5 class="hidden-xs hidden-sm"><span></span>section</h5>
<h5 class="hidden-md hidden-lg "><span></span>section</h5>
</div>
</div>
<div class="row">
<div class="col-xs-12 text-center hidden-form">
<span>X</span>
</div>
</div>
</div>
</form>
</div>
</div>
<script>(function(w,d,h){w[h]=w[h]||[];var f=d.getElementsByTagName('script')[0],j=d.createElement('script');j.async=true;j.src='//edge.chinapex.com.cn/cdn/container_q6sfjue.js';f.parentNode.insertBefore(j,f);})(window,document,'apxDataHub');</script>  <script>      (function (w, d, s, l, i) {          w[l] = w[l] || [];          w[l].push({              'gtm.start': new Date().getTime(),              event: 'gtm.js' });          var f = d.getElementsByTagName(s)[0],              j = d.createElement(s),              dl = l != 'dataLayer' ? '&l=' + l : '';          j.async = true;          j.src =              '//www.googletagmanager.com/gtm.js?id=' + i + dl;          f.parentNode.insertBefore(j, f);      })(window, document, 'script', 'dataLayer', 'GTM-5PSZVF');  </script>  <script type="text/javascript" id="">      window.ga = window.ga || function () {              (ga.q = ga.q || []).push(arguments)          };      ga.l = +new Date;      ga("create", "UA-24603463-1", "auto");  </script>  <script type="text/javascript" id="">      var _agt = _agt || [];      _agt.push(["_atscu", "AG_237441_XULS"]);      _agt.push(["_atsdomain", "juwai.com"]);      (function () {          var a = document.createElement("script");          a.type = "text/javascript";          a.async = !0;          a.src = ("https:" == document.location.protocol ? "https" : "http") + "://t.agrantsem.com/js/ag.js";          var b = document.getElementsByTagName("script")[0];          b.parentNode.insertBefore(a, b)      })();      function ag_237441_xuls_ats101(a) {          _agt = [];          _agt.push(["_atscu", "AG_237441_XULS"]);          _agt.push(["_atsdomain", "juwai.com"]);          _agt.push(["_atsev", "101"]);          _agt.push(["_atsusr", a]);          a = document.createElement("script");          a.type = "text/javascript";          a.async = !0;          a.src = ("https:" == document.location.protocol ? "https" : "http") + "://t.agrantsem.com/js/ag.js";          var b = document.getElementsByTagName("script")[0];          b.parentNode.insertBefore(a, b)      }      function agrant_send(a) {          ag_237441_xuls_ats101(a)      };  </script>
function gotoSend() {    var name_input = $("input[name=00N90000008PMXk]")    var phone_input = $("input[name=00N90000008PMXl]")    var email_input = $("input[name=00N90000008PMXj]")    if (name_input.val() == '') {        alert('姓名不能为空');        name_input.focus();        return false;    }    if (phone_input.val() == '') {        alert('手机号不能为空');        phone_input.focus();        return false;    }    var ph_reg = /^\d{8,}$/;    if (!ph_reg.test(phone_input.val())) {        alert("手机号格式不正确!");        phone_input.focus();        return false;    }    if (email_input) {        if (email_input.val() == '') {            alert("邮箱不能为空!");            email_input.focus();            return false;        }        var pat = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;        if (!pat.test(email_input.val())) {            alert('邮箱格式不正确');            email_input.focus();            return false }    }    var $submit = $(".submmit-form");    var form = $('#sendform');    var p_url = 'http://?c=collect&a=sale_force_data&url=' + $('#post_url').val();    if ($submit.attr("submitStatus") == undefined || $submit.attr("submitStatus") == "true") {        $.ajax({            type: "POST",            url: p_url,            data: form.serialize(),            dataType: "json",            beforeSend: function() {                $submit.attr("submitStatus", "false");            },            success: function(msg) {                if (msg.result == 1) {                  $("#alertMessage").modal({                    show:true });                  ga('send', 'event', 'submit', 'submit', '');                  apxDataHub.push({event:'Zhuanti-enquiry-submit'});                  var time=3;                  var timer=setInterval(function(){                    time--;                    $("#alertMessage .modal-body span").text(time);                    if(time===0){                      $("#alertMessage").modal('hide');                      clearInterval(timer);                    }                  },1000);                } else {                    alert('submit fail!');                }            },            error: function(data) {                alert('submit fail!');            },            complete: function() {                $submit.attr("submitStatus", "true");            }        });    }}