Jquery checks whether the two passwords are equal _ jquery

Source: Internet
Author: User
This article introduces the Jquery framework easyui to determine whether the two passwords are equal, and uses jQuery. validate verifies whether the two passwords in the form are consistent. If you need them, you can refer to Jquery easyui as a very good ui framework, however, in Form Verification, there is no commonly used verification to determine that the values in the two output boxes are equal, so I made the following extension.

$. Extend ($. fn. validatebox. defaults. rules, {/* must be equal to a field */pointer to: {validator: function (value, param) {return $ (param [0]). val () = value ;}, message: 'field mismatch '}});

Example:

Password: 
Confirm Password:

Set the validType attribute to ['# password.
Of course, to use this small plug-in, you must first reference the js library of jquery easyui.

I encountered a small problem when I used jQuery. validate to verify the two passwords in the form. This is the code I wrote:

$ ("# AspnetForm "). validate ({rules: {txtName: {required: true}, txtTrueName: {required: true}, txtPass: {required: true, minlength: 3}, txtTwoPass: {required: true, minlength: 3, failed to: "# txtPass"}, txtEmail: {required: true, email: true}, txtAddress: {required: true}, txtPhone: {required: true }}, messages: {txtName: {required: "* enter the user name"}, txtTrueName: {required: "* enter the name"}, txtPass: {required: "* enter the password", minlength: "* The password cannot be less than 3 characters"}, txtTwoPass: {required: "* enter the password", minlength: "* password cannot be less than 3 characters", failed to: "* enter the same value again"}, txtEmail: {required: "* enter your email", email: "* enter the correct email format"}, txtAddress: {required: "* enter the address"}, txtPhone: {required: "* enter the mobile phone number "}}});

Why do I keep prompting me when I enter the same password twice? I tried different browsers and different versions of validate.

I don't know if you have encountered similar problems. I have read many articles and summarized the ideas for solving the problems:

  • First, check whether the values of the two password types on the html page are assigned IDs.
  • Or, you can check whether two txtPass IDs exist on the page.
  • Or you can remove the pointer to and verify again to see if there are other errors.

I hope this article will give you some inspiration. Thank you for your reading. I will make persistent efforts in this article.

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.