ASP. NET verification control

Source: Internet
Author: User
ASP. NET provides developers with a complete set of server controls to verify whether user input information is valid. These controls are as follows:

1. requiredfieldvalidator: Verify a required field. If this field is not entered, information cannot be submitted.

2. comparevalidator: Comparison verification. Compare the values of two fields, such as passwords and passwords, and compare a field with a specific value.

3. rangevalidator: range verification. Verify whether a field is in a certain range. For example, if the score field is 0 ~ In the range of 100.

4. regularexpressionvalidator: Regular Expression verification. It verifies the format of user input fields based on regular expressions, such as email, ID card, and phone number.

5. customvalidator: You can use this control when running the customized client JavaScript or VBScript function.

So how do I use the verification control?

1. Run the command aspnet_regiis-C to copy the ASP. NET client script file.

2. Place the verification control on the right of the control to be verified.

3. Modify the controltovalidate attribute of the verification control to the name of the control to be verified.

4. Modify the errormessage attribute of the verification control to a more specific error description, such as "enter the correct email password", "inconsistent passwords", and "required fields.

5. If you are using requiredfieldvalidator, the verification control is required. This step is OK. However, if you are using several other controls, you need to make the following settings:

A. The comparevalidator control compares the values of the two controls. You must set the controltocompare, operator, and type attributes. To compare a control with a specific value, you must modify the valuetocompare, operator, and type attributes.

B. The rangevalidator control sets the minimum and maximum values in the minimunvalue and maximumvalue attributes respectively. You also need to change the type attribute to currency or integer.

C. regularexpress control: Use the validationexpress attribute to select a new regular expression from the list.

Finally, you must note that each field can be verified using multiple weekly verification controls.

 

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.