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.