Category Archives: Validation Control

How to use RegularExpression Validator in ASP.Net ?

In this asp.net article i will explain you how to use RegularExpression validation control in asp.net.

Here, we will understand RegularExpression validation validator control with an example.

RegularExpression calidator control mostly use for validate Internet E-mail address and Internet URL.

The Internet Email address must contain @ after some text and dot(.) before some text, then the address is right other wise the email address is invalid format.

Same way in Internet URL means internet website name or domain name must start with http://.

Now, first Design the web form with Three Texbox control, Name, Email and Website URL along with the one button control.

First, drag the RegularExpresion Validation control on webforms from toolbox.

RegularExpression Validation in asp.net

RegularExpression Validation in asp.net

In RegularExpression Validator control we must set below property :

ControlToValidate = TextBox control which will be validate.

ErrorMessage = Display the message when error occur.

Validation Expression = Select the expression for validation criteria.

Set the Validation Expression property of RegularExpression Validation control.

Select Internet e-mail address option for validate email address.

RegularExpression Validation in asp.net

RegularExpression Validation in asp.net

 

Set ControltoValidate, ErrorMessage and ValidationExpression property like below:

RegularExpression Validation in asp.net

RegularExpression Validation in asp.net

 

If you want to validate Internet URL then just select Internet URL option in Validationexpressions.

Select Internet URL for validate website URL.

RegularExpression Validation in asp.net

RegularExpression Validation in asp.net

If we select Internet URL option from expression then the property windows looks like below screen.

RegularExpression Validation in asp.net

RegularExpression Validation in asp.net

 

Now, Here is the output of RegularExpression validator control in asp.net.

In below screen we entered wrong email and website name then the regularexpression validator control shows the error message like Invalid Email and Invalid Url.

RegularExpression Validation in asp.net

RegularExpression Validation in asp.net

 

Now, In below screen we have entered write format email and internet url then the error message automatically remove from the screen.

RegularExpression Validation in asp.net

RegularExpression Validation in asp.net

I hope this RegularExpression validation control example will help you…

How to use RangeValidator Control in ASP.Net ?

In this asp.net article i will explain you how to use RangeValidator control in ASP.Net.

RangeValidator control is used to checks the input control’s value is within a specified range, Means input values must be between two values,  It has minimum and maximum value.

Generally we use RangeValidator control for Mobile no and Pincode Number.

The most important properties of the RangeValidator control are MaximumValue, MinimumValue, and Type.

We must specify the Range from Minimum values to Maximum Values and Type of Input Values.

MaximumValue – Specify the MaximumValue of Input Value
MinimumValue -Specity the MinimumValue of Input Value
Type – Specify the Data Type of Input Value

Now, we will learn how to use rangevalidator in asp.net with an example.

First design asp.net web form as follow:

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

Here is the HTML design code for above web form.

Now,  Drag and drop RangeValidator control on web forms like below.

rangevalidator in asp.net

How to use RangeValidator control in asp.net

Here, we validate the TextBox for Mobile Number. Mobile no must be 10 digit.

First set ControlToValidate property = textbox mobile  as below.
and set ErrorMessage = “Invalid Mobile !!”

Now , set the Minimum and Maximum value property of range validator control for mobile number.

For Mobile Number :

MinimumValue = 1111111111
MaximumValue = 9999999999
Type = Double

Below screen shows the if we entered 9 digit in mobile textbox then validator control shows the error message.

same thing for Pincode Number, Pincode number must be 6 digit.

For Pincode Number :

MinimumValue = 111111
MaximunValue = 999999

 

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

 

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

Now, we take another example for type string values.

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

Here set the RangeValidator control Property for String

MaximunValue = K
MinimumValue = D
Type = String

 

Here, the textbox allow only character between D and K.
Below screen we entered E, so it doesn’t shows the error message.

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

Here, we have entered B, then B is not between D and K so it will shows the ErrorMessage.

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

I hope this asp.net RangeValidator control example will help you…..

SetFocusOnError Property of Validation Control in ASP.Net

Here, we learn how to use SetFocusOnError Property of Validation Control in ASP.Net.

All validation control has a SetFocusOnError property.

If you set SetFocusOnError=True  then when this validation control fail and show the error message then our mouse focus automatically that failed control.

If we use multiple validation controls, multiple validation controls fail then first validation control gets focus.

Here we take SetFocusOnError example with Requiredfieldvalidatior control.

how to use SetFocusOnError property in asp.net

how to use SetFocusOnError property in asp.net

The ASP.Net web form design code is :

how to use SetFocusOnError property in asp.net

how to use SetFocusOnError property in asp.net

how to use SetFocusOnError property in asp.net

how to use SetFocusOnError property in asp.net

 

How to use RequiredFieldValidator Control in ASP.Net

In this article i will explain how to use RequiredFieldValidator control in ASP.Net.

RequirefieldVaidator control Checks that the validated control must contains a value. It cannot be empty.

The RequiredFieldValidator Control simply checks to see if something was entered into the HTML form element.

Here, is an example for understand RequiredFielValidator control.

First drag the RequiredFielValidator control on asp.net web form

Design ASP.Net web form with two textbox control along with two requiedfield validator control for each.

validation control in asp.net

How to user RequiedFielValidator control in ASP.Net

Here is output of our design, we have two Requiredfield validaor one for textbox name and other for textbox city.

The asp.net design HTML code is:

How to user RequiedFielValidator control in ASP.Net

How to user RequiedFielValidator control in ASP.Net

Now, go to  the Requiredfieldvalidator control property and set ErrorMessage and ControlToValidate property.

ErrorMessage display automatically the error message when our textbox will be blank.

validation control in asp.net

How to user RequiedFielValidator control in ASP.Net

Set the ControlToValidate property for identify the validated textbox.

validation control in asp.net

How to user RequiedFielValidator control in ASP.Net

In below screen if both textbox name and textbox city will be blank then both validator control show the ErrorMessage when we click the butoon control.

 

Here we have enter some value in textbox name and textbox city is blank, then validator control shows the error message for textbox city enter city !!.

How to user RequiedFielValidator control in ASP.Net

How to user RequiedFielValidator control in ASP.Net

How to user RequiedFielValidator control in ASP.Net

How to user RequiedFielValidator control in ASP.Net

 

Validationsummary Control in ASP.Net

The ValidationSummary control is used to display a summary of all the validation control error messages  in a single control on web forms in asp.net. We can also cay the valiudationsummary control is the summary of all the validation control error messages display on web forms.

The Validationsummary control display all the validation control error message at single place in asp.net.

lets understand validationsummary control with an example.

Design the asp.net web forms with four textbox and four validation control for each textbox and a button control along with the validationsummary control.

Here is the html code for design asp.net web forms.

Here is the design of web forms :

ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

In above asp.net web forms figure shows the design of web forms. we have taken four textbox control for name, city, pincode and mobile number and provide validation control for each.

Here, we take requiredfield validator for name and city textbox and Range validator for Mobile number and RegularExpression validator for Email Address.

Now, set the proper error message to all the validator control as per requirement. In below figure we set all the error messages to validation control.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

There are three method or layout for display validationSummary control on asp.net web forms. If we need to change the layout of validationSummary then set the DisplayMode property of control.

DisplayMode = Lkist, BulletList, SingleParagraph

Below, figure shows how to change or set DisplayMode property of validationSummary control in asp.net.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

If we set DisplayMode=BulletList then the validationsummary exmaple result look like below screen.

All the error messages are together listed as bullet list.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

Now, change the DisplayMode from Bulletlist to SingleParagraph shows like below.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

The Result for DisplayMode=SingleParagraph, all the error messages are displayed as single paragraph format.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

If we set DisplayMode=List, then validationsummary out put will be like this.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

There are another two property of validationsummary control we need to understand the first one is ShowMessageBox and ShowSumary.

The ShowMessageBox=true then validationsummary control error message display on alertbox like javascript box.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

Here, we set the SowMessageBox= true, we can see here all the validation messages in alert box.

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

The ShowSummary property used to show or hide the vaildationsummary error messages on web forms.

Here, we set ShowMessageBox=True and ShowSummary=False

How to use ValidationSummary Control in ASP.Net

How to use ValidationSummary Control in ASP.Net

I hope you will like this validationSummary control post with an example…….

Example of RangeValidator Control in ASP.Net

RangeValidator control is used to checks the input control’s value is within a specified range, Means input values must be between two values,  It has minimum and maximum value.

Generally we use RangeValidator control for Mobile no and Pincode Number.

The most important properties of the RangeValidator control are MaximumValue, MinimumValue, and Type.

We must specify the Range from Minimum values to Maximum Values and Type of Input Values.

Here, we understand the range validator control with an example for validating Mobile Number.

The mobile number must be 10 digit number.
Here, we have to set rangevalidator property for mobile number :
MaximunValue = 9999999999 and MinimumValue = 1000000000 and Type=Double
Below is the html design code for asp.net web forms.


 

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

 

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

 

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

 

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

 

How to use RangeValidator control in asp.net

How to use RangeValidator control in asp.net

 

CompareValidator Control in ASP.Net

  • CompareValidator control is used to compare/match the value of one input control to the value of another input control.
  • Mostly this control is used to Entering the Password detail in Registration  form.
  • For this control we must specify the input Datatype for comparison.
  • Input Type may be:
    – String 
    – Date 
    – Currency 
    – Integer
    – Double
  • Here we have to set two property for validation.
  • ControlToValidate The main input control means Original first password.
  • ControlToComapre The second input control which is compare with main control, means confim -password control.

use compare validator control in asp.net

How to use compare validator control in asp.net

use compare validator control in asp.net

How to use compare validator control in asp.net

 

use compare validator control in asp.net

How to use compare validator control in asp.net

 

use compare validator control in asp.net

How to use compare validator control in asp.net