jquery Validation plugin uses a preliminary

Source: Internet
Author: User

Validate is an excellent form verification plug-in, the initial use of the following methods:

(1) front page code:

<form id= "Form1" runat= "Server" >
<div class= "Divframe" >
<div class= "Divtitle" >
Please enter the following information
</div>
<div class= "Divcontent" >
<div>
User name: <br/>
<asp:textbox id= "txtUserName"runat=" Server ></asp:TextBox>
*<br/>
<span></span>
</div>
<div>
E-mail: <br/>
<asp:textbox id= "Txtemail"runat=" Server ></asp:TextBox>
*<br/>
<span></span>
</div>
</div>
<div class= "DIVBTN" >
<asp:button id= "Button1" runat= "Server" text= "commit"/>
</div>
</div>
</form>

(2) Script code:

<script type= "Text/javascript" src= "Scripts/jquery-1.4.2.js" >
</script>
<script type= "Text/javascript" src= "Scripts/jquery.validate.js" >
</script>
<script type= "Text/javascript" src= "Scripts/jquery.validate.messages_cn.js" >
</script>

<script type= "Text/javascript" >
$ (function () {
$ ("#form1"). Validate (
{
/* Custom Validation rules */
Rules: {
txtUserName: {required:true, minlength:6},
Txtemail: {required:true, email:true}
},
/* ERROR Tip location */
Errorplacement:function (Error, Element) {
Error.appendto (Element.siblings ("span"));
}
}
);
})
</script>

Jquery.validate.messages_cn.js is used to display the message in Chinese. When writing validation rules, be aware that the control's ID attribute is associated with the rule .

jquery Validation plugin uses a preliminary

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.