JQuery Validate Validation Customizations

Source: Internet
Author: User

Http://www.w3cschool.cc/jquery/jquery-plugin-validate.html

http://blog.163.com/zhao_jinggui/blog/static/169620429201172942347465/

$ (). Ready (function () {JQuery.validator.addMethod ("IsMobile", function (value, Element) {var length = Value.length; var mobile =/^ ((13[0-9]{1}) | (  15[0-9]{1})) +\d{8}) $/; return this.optional (Element) | | (length = = && Mobile.test (value)); }, "Please fill in your mobile phone number correctly");  JQuery.validator.addMethod ("Isphone", function (value, Element) {var length = Value.length; var phone =/(^ (\d{3,4}-)? \d{6,8}$) | (^ (\d{3,4}-)? \d{6,8} (-\d{1,5})? $) |  (\d{11})/; return this.optional (Element) | | (Phone.test (value));  }, "Please fill in the correct phone number");  JQuery.validator.addMethod ("Ischinese", function (value, Element) {var Chinese =/^[\ one-\ calls]+$/i; return this.optional (Element) | | (Chinese.test (value));  }, "Only input Chinese characters"); JQuery.validator.addMethod ("Ismypassword", function (value, Element,param) {//var specialstr =/[!,[email  protected]#$%^&*?_~]/;//var numberstr=/^ (\d+[a-za-z]\w*) | ([a-za-z]+\d\w*) $/;//return this.optional (Element) && (Numberstr.test (value)) && (Specialstr.test (          Value)); VAr regu1 =/[a-za-z]/;    var regu2=/\d/;             var regu3=/[!,[email protected]#$%^&*?_~]/;             var b1=regu1.test (value);             var b2=regu2.test (value);             var b3=regu3.test (value);    var b=b1&&b2&&b3; return b = = eval (param); }, "Password must be entered in letters and numbers"); $ ("#myform"). Validate ({rules: {userName: {required:true, Minlength:6, maxlength:200}, Userema    Il: {required:true, email:true}, Userpwd: {required:true, Minlength:8, ismypassword:true }, Confuserpwd: {required:true, Minlength:8, Equalto: "#userPwd"}, Userrname: {required:tr UE, Minlength:6, maxlength:200, ischinese:true}, Usermphone: {required:true, Ismobile:tru     e}, Userphone: {required:true, isphone:true}}, messages: {userName: {required: "Please enter user name",  MinLength: "Character length cannot be less than 6 characters", MaxLength: "character length cannot be greater than 200 characters"}, UserEmail: {  Required: "Please enter email address", Email: "Please enter the correct email address"}, Userpwd: {required: "Please enter password", minlength: "Character length cannot be less than 8 characters", Ismypassword: "The password must consist of a number, an English letter and a special character (!,[email protected]#$%^&*?_~)"}, Confuserpwd: {required: "Please enter a confirmation key Code ", minlength:" Character length cannot be less than 8 characters ", Equalto:" Two times password input inconsistent "}, Userrname: {required:" Please enter the real name ", minlength:" Word    cannot be less than 6 characters ", MaxLength:" character length cannot be greater than 200 characters ", Ischinese:" Only Chinese Characters "}, Usermphone: {required:" Please enter mobile phone number ",  IsMobile: "Please enter the correct mobile number"}, Userphone: {required: "Please enter phone number", Isphone: "Please enter the correct phone number"}}, Errorelement:    "Em", success:function (EM) {Em.text (""). AddClass ("Success"); } });  }); /* Form validation style */em {font-style:normal;/* font does not tilt */font-weight:500; padding-right:1em; vertical-align:middle; color:red;} Em.error {Background:url (".. /images/unchecked.gif ") no-repeat 0px 0px; padding-left:16px;} em.success {Background:url (".. /images/standard_msg_ok.gif ") no-repeat 0px 0px; Padding-left: 16px;} 

  

JQuery Validate Validation Customizations

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.