Add a custom checksum to the jquery validate

Source: Internet
Author: User

1, form submission when the prompt box

$ ("#form1"). Validate ({

Submithandler:function (form) {
if (confirm) (' Confirm modification. ') = = True) {
Message ("Processing form ...");
Form.submit ();
}else{
Window.location.reload ()//Add this sentence to clear the contents of the form
}
}

});

2, verify the contents of the input box must be a combination of letters, numbers, and special characters, and the length can not be less than 8

JQuery.validator.addMethod ("Checkpassword",
function (value,element) {
if (value.length==0)
{
return true;
}
if (value.length!=0&&value.length<8) {
return false;
}
Return/^[-\da-za-z ' =\\\[\]; ',./~!@#$%^&* () _+|{}: "<>?" * (\d+[a-za-z]+[-' =\\\[\]; ',./~!@#$%^&* () _+|{}: "<>?] +)| (\d+[-' =\\\[\]; ',./~!@#$%^&* () _+|{}: "<>?] +[a-za-z]+) | ([a-za-z]+\d+[-' =\\\[\]; ',./~!@#$%^&* () _+|{}: "<>?] +)| ([a-za-z]+[-' =\\\[\]; ',./~!@#$%^&* () _+|{}: "<>?] +\d+) | ([-' =\\\[\]; ',./~!@#$%^&* () _+| {}: "<>?] +\d+[a-za-z]+) | ([-' =\\\[\]; ',./~!@#$%^&* () _+| {}: "<>?] +[a-za-z]+\d+)) [-\da-za-z ' =\\\[\]; ',./~!@#$%^&* () _+|{}: "<>?] *$/.test (value);
},
"Password at least 8 digits, need to include numbers, letters, special characters");

3, the contents of the input box must be a combination of characters and letters

JQuery.validator.addMethod ("Alnum", function (value, Element) {
return this.optional (Element) | | /^[a-za-z].*[0-9].*[a-za-z]| [a-za-z].*[0-9]| [0-9].*[a-za-z]| [0-9].*[a-za-z].*[0-9]+$/.test (value);
}, "must be a combination of letters and numbers");

4, not equal to the verification, the contents of two input boxes if not equal through

JQuery.validator.addMethod ("NotEqual", function (value, element, param) {

var target = $ (param). Unbind (". Validate-equalto"). Bind ("Blur.validate-equalto", function () {$ (Element). valid ();

var targetvalue=target.val ();
return!value==targetvalue;

}, "Can't Be with ... Same ");

Use: notequal: #login ID of the input box in which login is to be compared

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.