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