As a beginner, the various jquery.validate.js tutorials on the internet are really not understood. So, he groped to write a simple small example, only for beginners to refer to. In a concise and understandable principle, removed a variety of CSS styles, JS special effects. Gossip less, attached source code.
<script src= "Jquery.js" type= "Text/javascript" ></script> <script src= "jquery.validate.js" text
/javascript "></script> <style type=" Text/css ">. msg_invalid {background-color: #FFF2F2;
border:1px solid #FFB6B6;
Color: #FF5243;
PADDING:6PX 10px;
} </style> <div id= "container" > <div class= "Mainbox setup_box" > <div class= "HD" >
Introduce the content of the Jquery.validate.js Plug-ins ignored, focus on the use of the method:
1. Introduce JS
<script src= "Jquery.js" type= "Text/javascript" ></script>
<script src= "Jquery.validate.js" type= "Text/javascript" ></script>
Many jquery.validate.js online can be downloaded.
2. How to use
1 The first: write directly in the code, such as the name of the commodity and the way commodity prices.
$ ("#apply_form"). validate{}
Among them, Apply_form is the form of id,rules is the validation rules;
Messages is the authentication method.
In addition, you use a style that prompts for information.
2 The second: direct use of class= "validation rules", such as the way of commodity inventory.
<pre name= "code" class= "HTML" > <input id= "Storage" name= "Storage" class= "required" >
This method uses the authentication information of the hint, originating from the Massege information in the Jquery.validate.js file. Please check the Jquery.validate.js file.
At this point, the validation rules can be used. If you cannot meet your requirements, you can customize the validation function.
For more in-depth tutorials, see: http://blog.csdn.net/phiberg/article/details/7344853