jQuery Validate插件实现表单强大的验证功能(2)

messages: { required: "This field is required.", remote: "Please fix this field.", email: "Please enter a valid email address.", url: "Please enter a valid URL.", date: "Please enter a valid date.", dateISO: "Please enter a valid date (ISO).", number: "Please enter a valid number.", mobile: "请填写正确的手机号码.", digits: "Please enter only digits.", creditcard: "Please enter a valid credit card number.", equalTo: "Please enter the same value again.", maxlength: $.validator.format("Please enter no more than {0} characters."), minlength: $.validator.format("Please enter at least {0} characters."), rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."), range: $.validator.format("Please enter a value between {0} and {1}."), max: $.validator.format("Please enter a value less than or equal to {0}."), min: $.validator.format("Please enter a value greater than or equal to {0}.") }

然后在methods中添加mobile的正则校验

mobile: function( value, element ) { return this.optional(element) || /^1[3|4|5|8][0-9]\d{8}$/.test(value); }

运行效果

jQuery Validate插件实现表单强大的验证功能

以上就是为大家展示的jQuery Validate 插件为表单提供了强大的验证功能,希望大家喜欢。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgwpfy.html