扩展jquery.validate
使用示例
JS正则表达式大全
http://www.blogjava.net/onejavaer/articles/79070.html
/*
* 中国移动号段大全:
2G手机号段大全:134、135、136、137、138、139、150、151、152、157、158、159;
3G手机号段大全:182、187、188;
中国联通号段大全:
2G手机号段大全:130、131、132、155、156;
3G手机号段大全:185、186;
中国电信号段大全:
2G手机号段大全:133、153;
3G手机号段大全:180、189
* 2011-10-31
* author LiuDong
* */
$.validator.addMethod('isMobile', function(value, element) {
var length = value.length;
return this.optional(element) || length == 11 &&
/^13[0-9]{1}[0-9]{8}$|^15[012356789]{1}[0-9]{8}$|^18[0256789]{1}[0-9]{8}$/.test(value);
}, '请输入有效的手机号码');
使用示例
$(function() {
$('#frmCustomerInfo').validate({
rules: {
'customer.contactTel': {
digits: true,
isMobile:"#customer.contactTel"
//range:
}
},
messages: {
'tel': '请输入目前有效手机号(数字且为11位!)'
}
});
});
JS正则表达式大全
http://www.blogjava.net/onejavaer/articles/79070.html