ASP.MVC 2.0 User Client Authentication example Explanation (3) _ Practical skills

Source: Internet
Author: User

Today to explain the next asp.net MVC client-side validation. Usually, we in the page for the input of the content to be client-side validation, client-side validation generally use JS, here we explain the use of Jquery.validate plug-ins for client authentication.
First let's look at the verification effect of the registration page

The above verification mainly includes
1. User name cannot be empty
2. Password can not be null, password length can not be less than 5 digits
3. Confirm password cannot be blank, Confirm password length cannot be less than 5 digits, confirm password must and password text box enter consistent
4. The mailbox format must be correct.

The following code is validated using the Jquery.validate plug-in

[HTML] <%@ Page language= "C #" inherits= "system.web.mvc.viewpage<mvclogin.models.registermodel>"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd  
 ">  

$ ("#form1"). Validate mainly includes rule rules and hint information messages two parts.
For example

Rules:
 {
 UserName:
 {
  required:true
 },
}

Indicates that the text box entered with ID username cannot be empty.

Messages:
 {
 UserName:
 {
  required: "<span style= ' color:red ' >" ¡ì name?) ¨¹ to be a null? </span> "
 },

Indicates the contents of a text box with an ID of username if empty, give a hint.

The above is the use of Jquery.validate plug-ins for client-side verification of the whole process, I hope to help you learn.

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.