atrn = /^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$|(^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$)/; // if ($(".form-input-phone").val() != ""){ // $(".form-input-phone").next().html(""); // }else{ // $(".form-input-phone").next().html("联系电话不能为空"); // aa = false; // } // console.log($(".form-input-phone").val()) var patrn = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; var email = $(this).parent().prevAll().find('.form-input-email'); if(email.val() != ""){ if (!patrn.exec(email.val())){ email.next().html("Incorrect mailbox format"); aa = false; }else{ email.next().html(""); } }else{ email.next().html("A valid email address is required."); aa = false; } if($(this).parent().prevAll().find('.form-input-message').val() != ""){ $(this).parent().prevAll().find('.form-input-message').next().html(""); }else{ $(this).parent().prevAll().find('.form-input-message').next().html("The message cannot be empty"); aa = false; } if(aa){ if($(this).attr("is_ck")=='true'){ return false; } var myDate = new Date(); var mytime=myDate.toLocaleTimeString(); //获取当前时间 var timedate = myDate.toLocaleString( ); //获取日期与时间 $(this).prop('disabled',true).attr("is_ck",'true').addClass(".disabled"); // console.log($(this)) $.ajax({ type : 'POST', dataType : 'json', url : "/wp-admin/admin-ajax.php", data : { 'action' : 'save_inquiry', 'time' : timedate, 'name' : $form.find('input[name=in_name]').val(), 'email' : $form.find('input[name=in_email]').val(), 'company': $form.find('input[name=in_company]').val(), 'phone' : $form.find('input[name=in_phone]').val(), 'url' : 'https://www.touchwo.cn/return-policy/', 'message': $form.find('textarea[name=in_message]').val(), 'channel': getCookie('incoming'), 'device' : device, }, success : function(data) { console.log(data) if(data.success == true){ // $form.find('.inquiry-form').html(data.message); // window.location.href = "/message/"; setCookie('inquiry',1); gtag_report_conversion("/message/"); } else { $form.find('.c-err-msg').html(data.message); setTimeout(function(){ $('.js-in-submit').prop('disabled',false).attr("is_ck",'false').removeClass(".disabled") },2000) } }, error :function(){ $form.find('.c-err-msg').html('Busy service'); setTimeout(function(){ $('.js-in-submit').prop('disabled',false).attr("is_ck",'false').removeClass(".disabled") },2000) } }); }else{ return false; } }); });