Describes how to use the jquery Form Verification plug-in validation.
I. How to Use
Introduce js files
<script src="jquery.js"></script><script src="jquery.validate-1.13.1.js"></script>
Compile the html page. Here, the user name and password are used as an example.
<Body> <form id = "demoForm"> <fieldset> <legend> User Logon </legend> <p> <label for = "username"> User Name </label> <input type = "text" id = "username" name = "username"> </p> <label for = "password"> password </label> <input type = "text" id = "password" name = "password"> </p> </fieldset> </form> </body>
Script writing
$ (Document ). ready (function () {$ ("# demoForm "). validate ({rules: {username: {required: true, // required? minlength: 2, // minimum length maxlength: 10 // maximum length}, password: {required: true, minlength: 2, maxlength: 16 }}});});
Ii. Test
If you want to learn more, click on two highlights: jquery Form Verification Daquan JavaScript Form Verification Daquan
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.