Jquery validate Verification

Source: Internet
Author: User

Introduced in JSP

 <script src="jquery-1.8.0.min.js" type="text/javascript"></script><script src="jquery.easyui.min.js" type="text/javascript"></script><script src="jquery.validate.js" type="text/javascript"></script>

Jquery. validate. js

$. Extend ($. fn. validatebox. defaults. rules, {minLength: {validator: function (value, param) {return value. length> = param [0] ;}, message: 'length must be greater than {0} characters. '}, maxLength: {validator: function (value, param) {return value. length <= param [0] ;}, message: 'length must be less than {0} characters. '}, maxCNLen: {validator: function (value, param) {var cArr = value. match (/[^ \ x00-\ xff]/ig); var len = value. length + (cArr = null? 0: cArr. length); return len <= param [0];}, message: 'The length must be less than {0} characters. Chinese is counted as 2 characters. '}, intOrFloat: {// verify the integer or decimal validator: function (value) {return/^ \ d + (\. \ d + )? $/I. test (value) ;}, message: 'enter a number and make sure the format is correct '}, idcard: {// verify the ID card validator: function (value) {return/^ \ d {15} (\ d {2} [A-Za-z0-9])? $/I. test (value) ;}, message: 'incorrect ID card number format '}, length: {validator: function (value, param) {var len = $. trim (value ). length; return len> = param [0] & len <= param [1];}, message: "The length of the input content must be between {0} and {1. "}, phone: {// verification phone number validator: function (value) {return/^ (\ d {2, 3 }\)) | (\ d {3 }\-))? (\ (0 \ d {2, 3} \) | 0 \ d {2, 3 }-)? [1-9] \ d {6, 7} (\-\ d {1, 4 })? $/I. test (value) ;}, message: 'The format is incorrect. Please use the following format: 020-88888888'}, mobile: {// verify the mobile phone number validator: function (value) {return/^ (13 | 15 | 18) \ d {9} $/I. test (value) ;}, message: 'incorrect Mobile Phone Number Format '}, currency: {// verification currency validator: function (value) {return/^ \ d + (\. \ d + )? $/I. test (value) ;}, message: 'currency format incorrect '}, qq: {// verify QQ, validator: function (value) from 10000) {return/^ [1-9] \ d {4, 9} $/I. test (value) ;}, message: 'incorrect QQ number format '}, integer: {// verification integer validator: function (value) {return/^ [+]? [1-9] + \ d * $/I. test (value) ;}, message: 'enter an integer '}, integerAndMaxLength: {validator: function (value, param) {return (value. length <= param [0]) & (/^ [+]? [1-9] + \ d * $/I. test (value) ;}, message: 'enter an integer of less than {0} characters. '}, integer: {// verify the fixed-length integer validator: function (value) {return/^ [+]? [1-9] + \ d * $/I. test (value) ;}, message: 'enter an integer '}, age: {// verify the age validator: function (value) {return/^ (?: [1-9] [0-9]? | 1 [01] [0-9] | 120) $/I. test (value) ;}, message: 'Age must be an integer between 0 and 120 '}, chinese: {// verify chinese validator: function (value) {return/^ [\ response-\ ¥] + $/I. test (value) ;}, message: 'enter Chinese '}, english: {// verify english validator: function (value) {return/^ [A-Za-z] + $/I. test (value) ;}, message: 'enter the English'}, unnormal: {// verify whether it contains spaces and invalid characters validator: function (value) {return /. +/I. test (value) ;}, message: 'enter value cannot be blank and contain other illegal characters '}, username: {// verify user name v Alidator: function (value) {return/^ [a-zA-Z] [a-zA-Z0-9 _] {5, 15} $/I. test (value) ;}, message: 'invalid User Name (starting with a letter, 6-16 bytes allowed, letter or digit underline allowed) '}, faxno: {// verify the fax validator: function (value) {// return/^ [+] {0, 1} (\ d) {1, 3} []? ([-]? (\ D) | [//]) {1, 12}) + $/I. test (value); return/^ (\ d {2, 3} \) | (\ d {3 }\-))? (\ (0 \ d {2, 3} \) | 0 \ d {2, 3 }-)? [1-9] \ d {6, 7} (\-\ d {1, 4 })? $/I. test (value) ;}, message: 'incorrect fax number '}, zip: {// verify the zip code validator: function (value) {return/^ [1-9] \ d {5} $/I. test (value) ;}, message: 'incorrect zip code format '}, ip: {// verify ip address validator: function (value) {return/d +. d +. d +. d +/I. test (value) ;}, message: 'IP address format incorrect '}, name: {// verify name, which can be Chinese or English validator: function (value) {return/^ [\ response-\ ¥] + $/I. test (value) |/^ \ w + [\ w \ s] + \ w + $/I. test (value) ;}, message: 'enter your name'}, date: {// verify your name, Can be Chinese or English validator: function (value) {// format yyyy-MM-dd Or yyyy-M-dreturn/^ (? :(?! (0000) [0-9] {4} ([-]?) (? :(?: 0? [1-9] | 1 [0-2]) \ 1 (?: 0? [1-9] | 1 [0-9] | 2 [0-8]) | (?: 0? [13-9] | 1 [0-2]) \ 1 (?: 29 | 30) | (?: 0? [1, 13578] | 1 [02]) \ 1 (?: 31) | (?: [0-9] {2 }(?: 0 [48] | [2468] [048] | [13579] [26]) | (?: 0 [48] | [2468] [048] | [13579] [26]) 00) ([-]?) 0? 2 \ 2 (?: 29) $/I. test (value) ;}, message: 'Enter the appropriate date format'}, msn: {validator: function (value) {return/^ \ w + ([-+.] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w +) * $ /. test (value) ;}, message: 'enter a valid msn account (for example, abc @ hotnail (msn/live ). com) '}, same: {validator: function (value, param) {if ($ ("#" + param [0]). val ()! = "" & Value! = "") {Return $ ("#" + param [0]). val () = value ;}else {return true ;}, message: 'The passwords entered twice are inconsistent! '}});

Example

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.