The example above is that we are a unified reference jquery.validate.js so all required fields are prompted with this field is required.
Now to change the dynamic prompt, for example, the name is assumed to be empty, the hint name cannot be empty, the password is assumed to be empty, the prompt password cannot be empty.
This time we officer the rules in the code.
First, the file is introduced first.
<script src= "Js/jquery-1.8.0.min.js" type= "Text/javascript" ></script><script src= "js/ Jquery.validate.js "type=" Text/javascript "></script>
Next, declare the following HTML fragment
<form action= "" id= "Jvform" > Name: <input type= "text" name= "username" id= "username"/></br> password:< Input type= "password" name= "password" id= "password"/></br><input type= "Submit" value= "Submit"/></form >
compared to the previous class= "required" .
The last check rule is for example the following:
$ (function () { $ ("#jvForm"). Validate ({ rules: { username: { required:true }, password: { Required:true } }, messages: { username: { required: "Name cannot be empty!" }, password: { Required: "Password cannot be empty!"}} );})
Execution Effect
JQuery validation makes validation so Easy (ii)