<script type="text/javascript" src="__PUBLIC__/Admin/js/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/js/lib/jquery.validation/1.14.0/validate-methods.js"></script>
$.validator.addMethod("emails",function(value,element,params){ if (params) { if (value=="") { return false; }else{ var x=value.split(';'); //console.log(x); for (var i = 0; i < x.length; i++) { //console.log(x[i]); if (x[i]!="") { var email = x[i]; var reg = /^\w+(\.\w+)*[@]{1}\w+[.]\w+$/; if(!reg.test(email)){ return false; } } } return true; } } },"必须是邮件地址格式和英文分号的组合"); $("#form-order-confirmation").validate({ rules:{ contact_email:{ emails:true } }, onkeyup:false, focusCleanup:true, success:"valid", submitHandler:function(form){ $(form).ajaxSubmit({ type: 'post', // 提交方式 get/post url: '{:U("Order/confirmation")}', // 需要提交的 url success: function(data) { // data 保存提交后返回的数据,一般为 json 数据 if(data.code == 10000) { layer.msg(data.data, {icon: 1,time:2000}); setTimeout(function(){ window.parent.location.reload(); var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); },2000); } else { layer.msg(data.data, {icon: 2,time:3000}); } }, error:function(){ layer.msg('未知错误!', {icon: 2,time:2000}); } }); return false; } });