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.