Home  >  Article  >  Web Front-end  >  JQuery validation tool class collection_jquery

JQuery validation tool class collection_jquery

WBOY
WBOYOriginal
2016-05-16 17:43:331082browse
Copy code The code is as follows:

var Validator = {
// Email
isEmail: function(s) {
var p = "^[-!#$%&'* \./0-9=?A-Z^_`a-z{|}~] @[-!#$%&'* \/0-9=?A-Z^_`a-z{|}~] .[-!#$%&'* \./0-9=?A-Z^_`a-z{|}~] $";
return this.test(s, p);
},

//Mobile phone number
isMobile: function(s) {
return this.test(s, /^(180 |189|133|134|153|181)d{8}$/);
},

// Phone number
isPhone: function(s) {
return this. test(s, /^[0-9]{3,4}-[0-9]{7,8}$/);
},

// Postcode
isPostCode: function(s) {
return this.test(s, /^[1-9][0-9]{5}$/);
},

// Number
isNumber : function(s, d) {
return !isNaN(s.nodeType == 1 ? s.value : s)
&& (!d || !this.test(s, '^-? [0-9]*\.[0-9]*$'));
},

// Determine whether it is empty
isEmpty: function(s) {
return !jQuery.isEmptyObject(s);
},

// Regular matching
test: function(s, p) {
s = s.nodeType == 1 ? s.value : s;
return new RegExp(p).test(s);
}
};
Statement:
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