Home > Web Front-end > JS Tutorial > body text

JQuery validation tool class collection_jquery

WBOY
Release: 2016-05-16 17:43:33
Original
1112 people have browsed it
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);
}
};
Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!