A simple example of jquery.validate.js validation __js

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.