Home > Web Front-end > JS Tutorial > jquery validate adds custom validation rules (validation email address postal code)_jquery

jquery validate adds custom validation rules (validation email address postal code)_jquery

WBOY
Release: 2016-05-16 17:10:51
Original
1270 people have browsed it


jQuery:validate to add custom validation

jQuery.validator.addMethod adds custom validation rules

addMethod:name, method, message

Simple example: adding a single verification

Copy code The code is as follows:




validate.js extended validation












邮编:

名字:





 

 validate.expand.js

 

复制代码 代码如下:

 jQuery.validator.addMethod("userName", function(value, element) {
    return this.optional(element) || /^[u0391-uFFE5w] $/.test(value);
}, "用户名必须在5-10个字符之间");  

jQuery.validator.addMethod("isZipCode", function(value, element) {  
    var tel = /^[0-9]{6}$/;
    return this.optional(element) || (tel.test(value));
}, "请正确填写您的邮政编码");
 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template