我想顯示這個效果,但實(shí)際是一點(diǎn)提交,顯示“請輸入聯(lián)系電話!”我的代碼如下//登錄表單驗(yàn)證?$(document).ready(function(){ ? $("#submitForm").validate({ rules: { ?company: {? ? ? ? ? ? ? ? ? ? ?required: true,? ? ? ? ? ? ? ? ? ? minlength: 2,? ? ? ? ? ? ? ? ? ? maxlength: 10 ? ? ? ? ? ? ? ? }, ? ? user: {? ? ? ? ? ? ? ? ? ? ?required: true,? ? ? ? ? ? ? ? ? ? minlength: 2,? ? ? ? ? ? ? ? ? ? maxlength: 10 ? ? ? ? ? ? ? ? }, ? ? phone: {? ? ? ? ? ? ? ? ? ? ?required: true,? ? ? ? ? ? ? ? ? ? ? isPhone: true ? ? ? ? ? ? ? ? ? } }, messages: { company: {? ? ? ? ? ? ? ? ? ? ?required: '請輸入公司名稱!',? ? ? ? ? ? ? ? ? ? minlength: '公司名稱不能小于2個字符!',? ? ? ? ? ? ? ? ? ? maxlength: '公司名稱不能超過10個字符!' ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? }, ? user: {? ? ? ? ? ? ? ? ? ? ?required: '請輸入聯(lián)系人姓名!',? ? ? ? ? ? ? ? ? ? minlength: '公司名稱不能小于2個字符!',? ? ? ? ? ? ? ? ? ? maxlength: '公司名稱不能超過10個字符!' ? ? ? ? ? ? ?? ? ? ? ? ? ? ? }, ? phone: { required: '請輸入聯(lián)系電話!', ?isPhone: '請輸入一個有效的聯(lián)系電話!' ? ? ? ? ? ?? } }, submitHandler: function (form) { ? ? ?//通過驗(yàn)證,運(yùn)行函數(shù)? ? ? ? ? ? ? ? console.log($(form).serialize()); ? ? ? ? //form表單序列號? ? ? ? }, groups:{ login:"company user phone" }, errorPlacement:function(error,element){ error.appendTo("#error_tip"); }, errorElement: "em", //用來創(chuàng)建錯誤提示信息標(biāo)簽 ?});? });??? // 聯(lián)系電話(手機(jī)/電話皆可)驗(yàn)證?jQuery.validator.addMethod("isPhone", function(value,element) {?? var mobile = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/;?? var tel = /^\d{3,4}-?\d{7,9}$/;?? return this.optional(element) || (tel.test(value) || mobile.test(value));?});?
添加回答
舉報
0/150
提交
取消