Asp.Net Validation
Validation Controls in Asp.Net
· ASP.NET Validation controls validate the user input Data. For restriction on Useless and redundant data.
There are basically 6 Types of Validation Control in asp.net.
1. Require Field Validation.
2. Range Validator.
3. Compare Validator
4. Regular expression validator.
5. Custom validator.
6. Validation summary.
1. Required Field Validator: -
This Validator ensures that the required field must require some value. Basically, that field does not fill empty.
2. Range Validator: -
This Validator ensures that input field must have values between some specific ranges.
3. Compare Validator: -
This Validator ensures that two different fields must contain the same values.
4. Regular expression validator: -
This Validator ensures that the field restricts with specific expression.
Email validation.
Phone number validation
Etc.
5. Custom Validator: -
This validator used when we want to create our own validation.
Let See Each Example in details
When we are working on Asp.net default validation controls we have to notice one thing.
- So lets Beggin... But I want some attractive Design on my web page so I'm just adding some bootstrap css here.
RequiredField Validation
- Required Field as per the name we can say that this field must require some value.
- whatever value is but value should not be null.
We can simply Drag and Drop this validation control from as shown list of validation control list before.
we have to modify its properties...
Let's see its properties...
the output of this Stuff looks like this...
Compare Validation
- As per the name, we can assume that it will compare two fields. Like the password field and confirm password field.
The Output of this field looks like this
Range Validator
- We are familiar with the word Range. Range specifies the boundaries.
- Range specifies its max value and its Min Value.
- if we are allowing that only 8 years to 16 years kids can register their account in my website.
- so you can create this stuff like this
It will work like this...
Regular Expression Validation
- The user can add any kind of data. and Registration page contains things like Email address, phone number, postal number etc.
- Each of the things has a pattern. like phone number must contain the digits. it may not allow characters or special characters. and we know that phone number must contain 10 digits.
- as same we know that Email-ID has a pattern like somevalue@google/yahoo.com/in etc.
- so we can restrict this kind of stuff with help of Ragular expression validation.
Custom Validation
- Normally Asp.Net web form supports almost all kind of validation. but it may possible that we need to create our own kind of validation control.
- or in simple words, we can say that we can create our own restriction with help of this validation...
- let's see this stuff in real time example...
Validation Summary
- Validation Summary is basically all conclusion of error.
- In simple words, it will return all error list in list form as I had show you below...





































Comments
Post a Comment