The errors that eventually appear on the page fall into two categories: the first is the default error message, which is already defined in the plugin and can be modified manually.
The second is the error message specified by the parameter, and the default error message is used if it is not specified. Modify the previous example's JS as follows:
Copy Code code as follows:
<script type= "Text/javascript" >
$ (function () {
$ ("#signupForm"). Validate (
The new section in the previous example
{
Rules: {
TxtPassword1: "Required",//password 1 required
TxtPassword2: {//Password 2 description More than 1 items using object type
Required:true,//required, here can be an anonymous method
Equalto: "#txtPassword1",//must be equal to password 1
Rangelength: [5, 10]//Length 5-10
},
Txtemail: "Email"//e-mail must be legal
},
Messages: {
TxtPassword1: "You must fill in",
TxtPassword2: {
Required: "You must fill in",
Equalto: "Password Inconsistent",
Rangelength: "String of length must be between {0} and {1}"
}
}
});
});
</script>
HTML is the same as the previous example
Added a messages item based on the previous example, specifying a value for the object type, which corresponds to the rules basic, purposely not specifying an email error message, and the results are as follows:
SOURCE download