Form juery verification in MVC
<SCRIPT type = "text/JavaScript">
$ (). Ready (function (){
$ ("# Frmreg"). Validate (
{
Errorelement: "Reg",/* plug-in will automatically generate a label after the text box and mark it as 'reg '. In this way, you can use Reg. success {} to control the style, remember Reg. do not leave spaces between success */
Success: function (Label ){
Label. Text (""). addclass ("success ");
},
Rules :{
Username :{
Required: True,
Minlength: 2,
Maxlength: 16
},
Email: {required: True, email: true },
Password :{
Required: True,
Minlength: 6,
Maxlength: 16
},
Confirmpassword: {required: True, failed to: "# password "},
Validate: {required: true}
}
}
);
});
</SCRIPT>
HTML code:
<Form action = "/account/register" method = "Post" id = "frmreg">
<Div class = "Left">
<Div class = "leadinfo"> enter the following information, all required: </div>
<Div class = "userinput">
<Ul class = "userinfo">
<Li> <SPAN class = "label"> account: </span> <input name = "username" id = "username" Title = "Both Chinese and English can contain no more than 8 Chinese characters or 16 characters"/> </LI>
<Li> <SPAN class = "label"> email account: </span> <input name = "email" id = "email" Title = "Please input email"/> </LI>
<Li> <SPAN class = "label"> logon password: </span> <input type = "password" name = "password" id = "password" Title = "Enter 6 to 16 digits or letters"/> </LI>
<Li> <SPAN class = "label"> Reset the password: </span> <input type = "password" name = "confirmpassword" id = "confirmpassword" Title = "repeat the above password"/> </LI>
<Li>
<Div> <SPAN class = "label"> Verification Code: </span> <input name = "Validate" id = "Validate" Title = "Enter the number in the image below"/> </div>
<Br/> <SPAN class = "moreinfo"> cannot see <a href = "javascript: refresh_captcha ()"> click here to refresh </a> </span>
</LI>
</Ul>
</Div>
<Div class = "c_gray" align = "center"> email account and nickname cannot be modified after registration. Check carefully. </Div> <br/>
<Div class = "useraction">
<Input name = "Submit" id = "Submit" type = "Submit" value = "complete registration" tabindex = "7" class = "btnnormal"/>
<Input type = "reset" id = "reset" value = "Refill" tabindex = "8" class = "btnnormal"/>
</Div>
<Div class = "leadinfo"> registered, <% = html. actionlink ("Log on", "Logon") %> </div>
<Input type = 'did' name = "gender" value = "-1"/>
<Input type = 'did' name = "city" value = "35"/>
<Input type = 'siden' name = "cburl" value = ""/>
</Div>
</Form>
<! -V: 3.2 -->