首页 > 代码库 > bootstrop

bootstrop

formValidate($form,getRules(),getMessages());

function getRules(){
return {
"memberViewVo.memberTel" : {
isTel :true
},
"memberViewVo.memberPhone" : {
required: true,
isMobile:true
}

};
}


function getMessages(){
return {
"memberViewVo.memberTel" : {
isTel :"电话格式有误,请重新输入 !"
},
"memberViewVo.memberPhone" : {
required: "请输入登录账号(手机号)!",
isMobile : "请输入正确的手机号!"
},

};
}

 

 

jQuery.validator.addMethod("isMobile", function(value, element) {
var length = value.length;
var mobile = /^(((13[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(15[0-9]{1}))+\d{8})$/;
return this.optional(element)
|| (length == 11 && mobile.test(value));
}, "请正确填写您的手机号码");
// 电话号码验证
jQuery.validator.addMethod("isTel", function(value, element) {
var tel = /^\d{3,4}-?\d{7,9}$/; //电话号码格式010-12345678
return this.optional(element) || (tel.test(value));
}, "请正确填写您的电话号码");

bootstrop