SlideShare a Scribd company logo
1 of 17
Validator in ASP.NET
Brought to you by
• ASP.NET validation controls validate the user input data to ensure
that useless, unauthenticated, or contradictory data don't get
stored.
• ASP.NET provides the following validation controls:
• RequiredFieldValidator
• RangeValidator
• CompareValidator
• RegularExpressionValidator
• CustomValidator
• ValidationSummary
• BaseValidator Class
• The validation control classes are inherited from the
BaseValidator class hence they inherit its properties and
methods. Therefore, it would help to take a look at the
properties and the methods of this base class, which are
common for all the validation controls:
Members Description
ControlToValidate Indicates the input control to validate.
Display Indicates how the error message is shown.
EnableClientScript Indicates whether client side validation will take.
Enabled Enables or disables the validator.
ErrorMessage Indicates error string.
Text Error text to be shown if validation fails.
IsValid Indicates whether the value of the control is valid.
SetFocusOnError It indicates whether in case of an invalid control, the focus should
switch to the related input control.
ValidationGroup The logical group of multiple validators, where this control belongs.
Validate() This method revalidates the control and updates the IsValid
property.
• RequiredFieldValidator Control
• The RequiredFieldValidator control ensures that the required
field is not empty. It is generally tied to a text box to force input
into the text box.
• The syntax of the control is as given:
• <asp:RequiredFieldValidator ID="rfvcandidate" runat="server"
ControlToValidate ="ddlcandidate" ErrorMessage="Please choose
a candidate" InitialValue="Please choose a candidate">
</asp:RequiredFieldValidator>
• RangeValidator Control
• The RangeValidator control verifies that the input value falls
within a predetermined range.
• The syntax of the control is as given:
• <asp:RangeValidator ID="rvclass" runat="server"
ControlToValidate="txtclass" ErrorMessage="Enter your
class (6 - 12)" MaximumValue="12" MinimumValue="6"
Type="Integer"> </asp:RangeValidator>
Properties Description
Type It defines the type of the data. The available values are:
Currency, Date, Double, Integer, and String.
MinimumValue It specifies the minimum value of the range.
MaximumValue It specifies the maximum value of the range.
• CompareValidator Control
• The CompareValidator control compares a value in one
control with a fixed value or a value in another control.
• The basic syntax of the control is as follows:
• <asp:CompareValidator ID="CompareValidator1"
runat="server" ErrorMessage="CompareValidator">
</asp:CompareValidator>
Properties Description
Type It specifies the data type.
ControlToCompare It specifies the value of the input control to compare with.
ValueToCompare It specifies the constant value to compare with.
Operator It specifies the comparison operator, the available values are:
Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan,
LessThanEqual, and DataTypeCheck.
• RegularExpressionValidator
• The RegularExpressionValidator allows validating the input text
by matching against a pattern of a regular expression. The regular
expression is set in the ValidationExpression property.
• The syntax of the control is as given:
• <asp:RegularExpressionValidator ID="string" runat="server"
ErrorMessage="string" ValidationExpression="string"
ValidationGroup="string"> </asp:RegularExpressionValidator>
Character Escapes Description
b Matches a backspace.
t Matches a tab.
r Matches a carriage return.
v Matches a vertical tab.
f Matches a form feed.
n Matches a new line.
 Escape character.
Metacharacters Description
. Matches any character except n.
[abcd] Matches any character in the set.
[^abcd] Excludes any character in the set.
[2-7a-mA-M] Matches any character specified in the range.
w Matches any alphanumeric character and underscore.
W Matches any non-word character.
s Matches whitespace characters like, space, tab, new line etc.
S Matches any non-whitespace character.
d Matches any decimal character.
D Matches any non-decimal character.
Quantifier Description
* Zero or more matches.
+ One or more matches.
? Zero or one matches.
{N} N matches.
{N,} N or more matches.
{N,M} Between N and M matches.
• CustomValidator
• The CustomValidator control allows writing application specific custom validation
routines for both the client side and the server side validation.
• The client side validation is accomplished through the ClientValidationFunction
property. The client side validation routine should be written in a scripting language,
such as JavaScript or VBScript, which the browser can understand.
• The server side validation routine must be called from the control's ServerValidate
event handler. The server side validation routine should be written in any .Net
language, like C# or VB.Net.
• The basic syntax for the control is as given:
• <asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction=.cvf_func. ErrorMessage="CustomValidator">
</asp:CustomValidator>
• ValidationSummary
• The ValidationSummary control does not perform any validation but shows a
summary of all errors in the page. The summary displays the values of the
ErrorMessage property of all validation controls that failed validation.
• The following two mutually inclusive properties list out the error message:
• ShowSummary : shows the error messages in specified format.
• ShowMessageBox : shows the error messages in a separate window.
• The syntax for the control is as given:
• <asp:ValidationSummary ID="ValidationSummary1" runat="server"
DisplayMode = "BulletList" ShowSummary = "true" HeaderText="Errors:" />
• Validation Groups
• Complex pages have different groups of information
provided in different panels. In such situation, a need might
arise for performing validation separately for separate
group. This kind of situation is handled using validation
groups.
• To create a validation group, you should put the input
controls and the validation controls into the same logical
group by setting their ValidationGroupproperty.
Thank You
For more updates subscribe to our YouTube channel
SIRYMEDIA
To watch more videos visit our website
www.sirymedia.in

More Related Content

What's hot (20)

Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
validations in asp .net
validations in asp .netvalidations in asp .net
validations in asp .net
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
Introduction to validation
Introduction to validationIntroduction to validation
Introduction to validation
 
Chapter 3 (validation control)
Chapter 3 (validation control)Chapter 3 (validation control)
Chapter 3 (validation control)
 
What are Anypoint Validations With Mulesoft
What are Anypoint Validations With Mulesoft What are Anypoint Validations With Mulesoft
What are Anypoint Validations With Mulesoft
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Asp.net html server control
Asp.net html  server controlAsp.net html  server control
Asp.net html server control
 
Visual studio 2008 asp net
Visual studio 2008 asp netVisual studio 2008 asp net
Visual studio 2008 asp net
 
Advanced Rational Performance Tester reports
Advanced Rational Performance Tester reportsAdvanced Rational Performance Tester reports
Advanced Rational Performance Tester reports
 
Angular Form Validations
Angular Form ValidationsAngular Form Validations
Angular Form Validations
 
Angular performance improvments
Angular performance improvmentsAngular performance improvments
Angular performance improvments
 
IBM Performance Optimizaiton Toolkit for Rational Performance Tester
IBM Performance Optimizaiton Toolkit for Rational Performance TesterIBM Performance Optimizaiton Toolkit for Rational Performance Tester
IBM Performance Optimizaiton Toolkit for Rational Performance Tester
 
Standard control in asp.net
Standard control in asp.netStandard control in asp.net
Standard control in asp.net
 
Ajaxppt
AjaxpptAjaxppt
Ajaxppt
 
Wheels
WheelsWheels
Wheels
 
Asp dot net final (2)
Asp dot net   final (2)Asp dot net   final (2)
Asp dot net final (2)
 
Clean VIP (Clean Swift) architecture
Clean VIP (Clean Swift) architectureClean VIP (Clean Swift) architecture
Clean VIP (Clean Swift) architecture
 

Similar to Validation in asp.net

validation-controls.pdf ioue8n uoh souu o3i
validation-controls.pdf ioue8n uoh souu  o3ivalidation-controls.pdf ioue8n uoh souu  o3i
validation-controls.pdf ioue8n uoh souu o3iCoRRexGaMing
 
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptxvnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptxYamunaS38
 
PERFORMANCE TESTING USING LOAD RUNNER
PERFORMANCE  TESTING  USING  LOAD RUNNERPERFORMANCE  TESTING  USING  LOAD RUNNER
PERFORMANCE TESTING USING LOAD RUNNERAjithaG9
 
LAYERS asp.net ppt
LAYERS asp.net pptLAYERS asp.net ppt
LAYERS asp.net pptIMEI
 
MVC 3-RAZOR Validation
MVC 3-RAZOR ValidationMVC 3-RAZOR Validation
MVC 3-RAZOR ValidationKrunal Trivedi
 
Introduction to Custom Form Control
Introduction to Custom Form ControlIntroduction to Custom Form Control
Introduction to Custom Form ControlKnoldus Inc.
 
Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Ilio Catallo
 

Similar to Validation in asp.net (20)

validation-controls.pdf ioue8n uoh souu o3i
validation-controls.pdf ioue8n uoh souu  o3ivalidation-controls.pdf ioue8n uoh souu  o3i
validation-controls.pdf ioue8n uoh souu o3i
 
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptxvnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
vnd.openxmlformats-officedocument.presentationml.presentation&rendition=1.pptx
 
validation of aap.net
validation of aap.netvalidation of aap.net
validation of aap.net
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 
OmniFaces validators
OmniFaces validatorsOmniFaces validators
OmniFaces validators
 
validation
validationvalidation
validation
 
PERFORMANCE TESTING USING LOAD RUNNER
PERFORMANCE  TESTING  USING  LOAD RUNNERPERFORMANCE  TESTING  USING  LOAD RUNNER
PERFORMANCE TESTING USING LOAD RUNNER
 
Spring REST Request Validation
Spring REST Request ValidationSpring REST Request Validation
Spring REST Request Validation
 
LAYERS asp.net ppt
LAYERS asp.net pptLAYERS asp.net ppt
LAYERS asp.net ppt
 
MVC 3-RAZOR Validation
MVC 3-RAZOR ValidationMVC 3-RAZOR Validation
MVC 3-RAZOR Validation
 
Defending against Injections
Defending against InjectionsDefending against Injections
Defending against Injections
 
Introduction to Custom Form Control
Introduction to Custom Form ControlIntroduction to Custom Form Control
Introduction to Custom Form Control
 
Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3Validation in Jakarta Struts 1.3
Validation in Jakarta Struts 1.3
 
Ch3 server controls
Ch3 server controlsCh3 server controls
Ch3 server controls
 
13090016_vectorcast.ppt
13090016_vectorcast.ppt13090016_vectorcast.ppt
13090016_vectorcast.ppt
 
Overview of Instrument Calibration
Overview of Instrument CalibrationOverview of Instrument Calibration
Overview of Instrument Calibration
 
Web controls
Web controlsWeb controls
Web controls
 
Project1 VB
Project1 VBProject1 VB
Project1 VB
 
Project1 CS
Project1 CSProject1 CS
Project1 CS
 
Fluent validation
Fluent validationFluent validation
Fluent validation
 

More from Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
31cs
31cs31cs
31cs
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 

Recently uploaded

MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 

Recently uploaded (20)

MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 

Validation in asp.net

  • 2. • ASP.NET validation controls validate the user input data to ensure that useless, unauthenticated, or contradictory data don't get stored. • ASP.NET provides the following validation controls: • RequiredFieldValidator • RangeValidator • CompareValidator • RegularExpressionValidator • CustomValidator • ValidationSummary
  • 3. • BaseValidator Class • The validation control classes are inherited from the BaseValidator class hence they inherit its properties and methods. Therefore, it would help to take a look at the properties and the methods of this base class, which are common for all the validation controls:
  • 4. Members Description ControlToValidate Indicates the input control to validate. Display Indicates how the error message is shown. EnableClientScript Indicates whether client side validation will take. Enabled Enables or disables the validator. ErrorMessage Indicates error string. Text Error text to be shown if validation fails. IsValid Indicates whether the value of the control is valid. SetFocusOnError It indicates whether in case of an invalid control, the focus should switch to the related input control. ValidationGroup The logical group of multiple validators, where this control belongs. Validate() This method revalidates the control and updates the IsValid property.
  • 5. • RequiredFieldValidator Control • The RequiredFieldValidator control ensures that the required field is not empty. It is generally tied to a text box to force input into the text box. • The syntax of the control is as given: • <asp:RequiredFieldValidator ID="rfvcandidate" runat="server" ControlToValidate ="ddlcandidate" ErrorMessage="Please choose a candidate" InitialValue="Please choose a candidate"> </asp:RequiredFieldValidator>
  • 6. • RangeValidator Control • The RangeValidator control verifies that the input value falls within a predetermined range. • The syntax of the control is as given: • <asp:RangeValidator ID="rvclass" runat="server" ControlToValidate="txtclass" ErrorMessage="Enter your class (6 - 12)" MaximumValue="12" MinimumValue="6" Type="Integer"> </asp:RangeValidator>
  • 7. Properties Description Type It defines the type of the data. The available values are: Currency, Date, Double, Integer, and String. MinimumValue It specifies the minimum value of the range. MaximumValue It specifies the maximum value of the range.
  • 8. • CompareValidator Control • The CompareValidator control compares a value in one control with a fixed value or a value in another control. • The basic syntax of the control is as follows: • <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator"> </asp:CompareValidator>
  • 9. Properties Description Type It specifies the data type. ControlToCompare It specifies the value of the input control to compare with. ValueToCompare It specifies the constant value to compare with. Operator It specifies the comparison operator, the available values are: Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, and DataTypeCheck.
  • 10. • RegularExpressionValidator • The RegularExpressionValidator allows validating the input text by matching against a pattern of a regular expression. The regular expression is set in the ValidationExpression property. • The syntax of the control is as given: • <asp:RegularExpressionValidator ID="string" runat="server" ErrorMessage="string" ValidationExpression="string" ValidationGroup="string"> </asp:RegularExpressionValidator>
  • 11. Character Escapes Description b Matches a backspace. t Matches a tab. r Matches a carriage return. v Matches a vertical tab. f Matches a form feed. n Matches a new line. Escape character.
  • 12. Metacharacters Description . Matches any character except n. [abcd] Matches any character in the set. [^abcd] Excludes any character in the set. [2-7a-mA-M] Matches any character specified in the range. w Matches any alphanumeric character and underscore. W Matches any non-word character. s Matches whitespace characters like, space, tab, new line etc. S Matches any non-whitespace character. d Matches any decimal character. D Matches any non-decimal character.
  • 13. Quantifier Description * Zero or more matches. + One or more matches. ? Zero or one matches. {N} N matches. {N,} N or more matches. {N,M} Between N and M matches.
  • 14. • CustomValidator • The CustomValidator control allows writing application specific custom validation routines for both the client side and the server side validation. • The client side validation is accomplished through the ClientValidationFunction property. The client side validation routine should be written in a scripting language, such as JavaScript or VBScript, which the browser can understand. • The server side validation routine must be called from the control's ServerValidate event handler. The server side validation routine should be written in any .Net language, like C# or VB.Net. • The basic syntax for the control is as given: • <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction=.cvf_func. ErrorMessage="CustomValidator"> </asp:CustomValidator>
  • 15. • ValidationSummary • The ValidationSummary control does not perform any validation but shows a summary of all errors in the page. The summary displays the values of the ErrorMessage property of all validation controls that failed validation. • The following two mutually inclusive properties list out the error message: • ShowSummary : shows the error messages in specified format. • ShowMessageBox : shows the error messages in a separate window. • The syntax for the control is as given: • <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode = "BulletList" ShowSummary = "true" HeaderText="Errors:" />
  • 16. • Validation Groups • Complex pages have different groups of information provided in different panels. In such situation, a need might arise for performing validation separately for separate group. This kind of situation is handled using validation groups. • To create a validation group, you should put the input controls and the validation controls into the same logical group by setting their ValidationGroupproperty.
  • 17. Thank You For more updates subscribe to our YouTube channel SIRYMEDIA To watch more videos visit our website www.sirymedia.in