The Jquery Easyui is a very good UI framework, but there is no most common validation in form validation for the equality of values in the two output boxes, so I did an extension.
$.extend ($.fn.validatebox.defaults.rules, {/
* must be equal to a field/*
Equalto: {
validator:function (Value,param) {return
$ (param[0]). val () = = value;
}, Message
: ' Field mismatch '
}
};
Use examples:
Password: <input id= "password" name= "password" validtype= "length[4,32" class= "Easyui-validatebox" required= "true" type= "Password" value= "/>
<br/>
Confirm password: <input type=" password "name=" Repassword "id=" Repassword " Required= "true" class= "Easyui-validatebox" validtype= "equalto[' #password ']" invalidmessage= "two-time input password mismatch"/>
You can specify the Validtype property as equalto[' #password '.
Of course Use this widget, must first reference jquery Easyui JS Library.
Using Jquery.validate to verify that the two passwords in the form are consistent is a little bit of a problem, and this is the code I wrote:
$ ("#aspnetForm"). Validate ({rules: {txtname: {required:true}, txttr Uename: {required:true}, Txtpass: {required:true, minlength: 3}, Txttwopass: {required:true, Minlength:3, Equalto: "#txtPas S "}, Txtemail: {required:true, email:true}, Txtaddres
S: {required:true}, Txtphone: {required:true}}, Messages: {txtname: {required: "* Please enter user name"}, Txttruename: {requ
ired: "* Please enter Name"}, Txtpass: {required: "* Please enter password", minlength: "* Password cannot be less than 3 characters" }, Txttwopass: {required: "* Please enter confirmation password", minlength: "* Password cannot be less than 3 characters", equal
To: "* Please enter the same value again" }, Txtemail: {required: "* Please enter the mailbox", Email: "* Please enter the correct mailbox format"}, Txtadd
Ress: {required: "* Please enter Address"}, Txtphone: {required: "* Please enter your mobile number"}
}
});
Why do I enter the password two times is consistent and always prompted me? You've tried different browsers and different versions of validate.
I do not know if you have encountered similar problems, I have consulted a number of articles, summed up the problem-solving ideas:
- First go to see if the two password of the HTML page are assigned a value ID.
- Or retrieve the two-Txtpass ID of the next page.
- Or you can remove the Equalto first, in the re-verification, to see if there are other errors, did not come back to troubleshoot the place.
I hope this article can give you some inspiration, thank you for reading, small series will continue to redouble their efforts.