Validation in Asp.Net

$INeed$

Well-Known Member
Validation is one of the most important tools used in building online forms for eample; online registration forms.

There are many validation tools.

Types:

1. Required field validator

2. Range validator

3. Regular ExpressionValidator

4. Compare Validator

5. Custom Validator

6. Validation Summary

Properties:

i)control to validate

ii)control to compare

iii)operator

iv)type

v)error message

Mainly validation tools are implemented using the properties windows rather than coding

Here I will show you with a example of a online registration form of a online shopping website with all types of validation.

Picture
In the above screenshots we can see that all the validation are Required Field Validation.

Now how we can apply such validation:

Step 1: just drag or double click the “required filed validator” from the tool box.

Step 2:Then selecting the validator tool type f4.The properties window will open.From there you have to change the properties.

Step 3:Change the Properties like

i)control to validate: this a very important property.You have to select the tool on which you want to create a validation.For eg. Textboxs,radio buttons etc.

ii)Error Message: where you can change the message which will appear when some one does’nt fill up the textbox.For example: here in the above screenshots I have given many error messages(in red) eg. “name required”,”user name not entered” etc.

Second example of a Compare Validation:

In the above screenshots we can see that the validation is Compare Validation.This type of validation is always used during password confirmation.

Now how we can apply such validation:

Step 1: just drag or double click the “CompareValidator” from the tool box.

Step 2:Then selecting the validator tool type f4.The properties window will open.from there you have to change the properties.

Step 3: Change Properties like

i)control to validate: Similarly like the above example a you have to select the tool on which you want to create the validation.For eg. Textboxs.

ii)control to compare:You have to choose the another textboxs with which you want to compare the text

ii)Error Message: Same as above.The difference is that if both the keywords entered in the two textboxs doesn't match then only the message will appear.For example: here in the above screenshots I have given “password and confirm password not match”.
 

Горе