SlideShare a Scribd company logo
1 of 28
Download to read offline
Validation Controls
Prepared by
Rajani Khushal K
Introduction
• Validating a form is most important part of
Website Development.
• User enters data of his or her choice; you
need that entered data in specific format.
• Initially for validating controls we used to
write JavaScript’s.
Introduction
• But it took more number of lines of code
and more time.
• With Validation controls this could be done
in couple of minutes.
Types of Validation
• Client Side Validation:
– It means the checking of data format or
validation is done at Client Side.
– It is done by the browser itself.
– The Client Side validation gives faster
response to Client.
Types of Validation
• Server Side Validation:
– It means the checking of data format or
validation is carried out at Server Side.
– Even though the data is checked at client
side, the data is again validated at Server
Side, so that the attacker or hacker cannot
manipulate the data on the browser side.
What are Validation Controls?
• The Controls that are used to validate the
data against some input format are known
as Validation Controls.
• If the data does not pass the validation, it
will display an error message to the user
and he would be able to submit the data.
Different Types of Validation
Controls
• RequiredFieldValidator
• CompareValidator
• CustomValidator
• RangeValidator
• RegularExpressionValidator
• ValidationSummary
RequiredFieldValidator Control
• The RequiredFieldValidator control is used to
make an input control a required field.
• With this control, the validation fails if the input
value does not change from its initial value. By
default, the initial value is an empty string ("").
• The basic syntax is given as:
– <asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="This
field can not be blank.">
</asp:RequiredFieldValidator>
CompareValidator Controls
• The CompareValidator control is used to
compare the value of one input control to
the value of another input control or to a
fixed value.
• The basic syntax for controls is:
– <asp:CompareValidator ID="CompareText"
runat="server"
ControlToCompare="TextBox1"
ControlToValidate="TextBox2"
ErrorMessage="Test Does not match" />
RangeValidator Controls
• The RangeValidator control is used to check that
the user enters an input value that falls between
two values.
• It is possible to check ranges within numbers,
dates, and characters.
• The basic syntax is given as:
– <asp:RangeValidator ID="Validator1" runat="server"
ControlToValidate="TextBox1"
ErrorMessage="Please enter no between 20 to 40."
MaximumValue="40" MinimumValue="20“
Type="Integer"></asp:RangeValidator>
RegularExpressionValidator
Control
• The RegularExpressionValidator control is
used to ensure that an input value
matches a specified pattern.
• It is powerful tool which is used to check
against specific types of values which may
be string, integer, data, mixed etc.
• For example:
– Input Mobile no in a specific format
– To input zip code of 6 digits only.
– To input Email address
RegularExpressionValidator
Symbols
Character Description
w Any word character (letter, number or underscore)
d Any digit
D Any character that is not Digit
s Any white space character like tab or space
S Any non white space character
| To specify one of the given choices
[ ] To specify a range of character or set of characters
[^ ] To specify opposite of specified characters.
* To specify zero or more number of characters
+ To specify one or more number of characters
RegularExpressionValidator
Symbols
Expression Meaning
w{10} Allow only 0 character which can be Letter, Number or
Underscore
w{5,10} Allows character between length 5 to 10
w{5,} Allows characters with minimum length 5
d{5} Allows only 5 digits
[M | m | F | f] Allows one of M, m, F or F
[A - D] Allows any one between A to D
[^A - D]{5} Allows 5 characters except from A to D
[A - D]* Allows zero or any no of characters between A to D
S{10} Allows 10 non white space characters
RegularExpressionValidator
Symbols
Use Example
Zip Code 361002
Mobile No. +91 - 9999999999
Email test@gmail.com
Product code B- 2345
Choice Y or y or N or n
Symbol
d {6}
+d{2} - d{10}
S+@S+.S+
[A-D] - d{4}
[Y | y | N | n]
• The syntax can be given as:
– <asp:RegularExpressionValidator
ControlToValidate="txtbox1"
ValidationExpression="d{6}"
EnableClientScript="false"
ErrorMessage="The zip code must be 5
numeric digits!"
runat="server" />
CustomValidator Controls
• The CustomValidator control allows you to
write a method to handle the validation of
the value entered.
• CustomValidator control allows us to
specify our own functions:
– Server Side Validation Functions
– Client Side Validation Functions
CustomValidator Controls
• Server side Validation Function:
– It is executed on server side.
– The name of the server side function is
ServerValidate function.
– The function name is automatically added
after the control name.
CustomValidator Controls
• Server side Validation Function:
– For example:
protected void cusCustom_ServerValidate(object o,
ServerValidateEventArgs e)
{
if (e.Value.Length == 8)
e.IsValid = true;
else
e.IsValid = false;
}
CustomValidator Controls
• Server side Validation Function:
– It has two main arguments:
– Object Source:
• Source name of control.
– ServerValidateEventArgs e:
• It will give us two important properties about the
control.
– e.Value
» This will give us value of control
– e.IsValid
» It can set to true or false. It depends on the choice of
checking.
CustomValidator Controls
• Client Side Validation Function:
– This is used to perform client side validation
function name.
– It has two property:
• ClientValidationFunction
• ValidateEmptytext
CustomValidator Controls
• Client Side Validation Function:
<script language="JavaScript">
function validateNumber(oSrc, args) {
args.IsValid = (args.Value % 5 == 0);
}
</script>
CustomValidator Controls
• Server Side Validate Function will be
checked when its value will be submitted
to the server.
• While Client Side Validate Function will be
checked as soon as control loses focus.
CustomValidator Controls
• The syntax can be given as:
– <asp:CustomValidator
ControlToValidate="txt1"
ClientValidationFunction ="user“
OnServerValidatie=“test_ServerVali”
Text="A username must be between 8 and 16
characters!"
runat="server"/>
ValidationSummary Controls
• The ValidationSummary control is used to
display a summary of all validation errors
occurred in a Web page.
• The error message displayed in this
control is specified by the ErrorMessage
property of each validation control.
• If the ErrorMessage property of the
validation control is not set, no error
message is displayed for that validation
control.
ValidationSummary Controls
• It has four property:
– DisplayMode: Mode of displaying all the
errors. It can be List, BulletList or single
Paragraph.
– HeaderText: We can give the header of
validation summary.
– ShowMessageBox: It is Boolean property
which is used to see error list as MessageBox
– ShowSummary: It is Boolean property which
is used to see error list as Summary.
• The syntax can be given as:
– <asp:ValidationSummary
ID="ValidationSummary1"
HeaderText="You must enter a value in the
following fields:"
ShowMessageBox="true"
ShowSummary="false"
EnableClientScript="true"
runat="server"/>
Validation Group
• Validation Group is a new feature that was
included in ASP.NET 2.0 version.
• The validation group helps you to group
the controls of a single page into separate
groups, so that you can submit each group
separately.
• Each group will have separate validation
controls.
Validation Group
• When you submit a group of values from a
group, only the validation controls which
are intended for that group would be
executed.
• This grouping of controls is achieved in
ASP.Net 2.0 by modifying the property
called the ValidationGroup property.

More Related Content

Similar to validation-controls.pdf ioue8n uoh souu o3i

Similar to validation-controls.pdf ioue8n uoh souu o3i (20)

Validation controls ppt
Validation controls pptValidation controls ppt
Validation controls ppt
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
validations in asp .net
validations in asp .netvalidations in asp .net
validations in asp .net
 
Validation controls ASP .NET
Validation controls ASP .NETValidation controls ASP .NET
Validation controls ASP .NET
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 
Chapter 3 (validation control)
Chapter 3 (validation control)Chapter 3 (validation control)
Chapter 3 (validation control)
 
Project1 CS
Project1 CSProject1 CS
Project1 CS
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
validation
validationvalidation
validation
 
Project1 VB
Project1 VBProject1 VB
Project1 VB
 
ASP.NET Validation Control
ASP.NET Validation ControlASP.NET Validation Control
ASP.NET Validation Control
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
What are Anypoint Validations With Mulesoft
What are Anypoint Validations With Mulesoft What are Anypoint Validations With Mulesoft
What are Anypoint Validations With Mulesoft
 
Defending against Injections
Defending against InjectionsDefending against Injections
Defending against Injections
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
 
My journey to use a validation framework
My journey to use a validation frameworkMy journey to use a validation framework
My journey to use a validation framework
 
validation
validationvalidation
validation
 
Visual studio 2008 asp net
Visual studio 2008 asp netVisual studio 2008 asp net
Visual studio 2008 asp net
 

Recently uploaded

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
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

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
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
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
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

validation-controls.pdf ioue8n uoh souu o3i

  • 2. Introduction • Validating a form is most important part of Website Development. • User enters data of his or her choice; you need that entered data in specific format. • Initially for validating controls we used to write JavaScript’s.
  • 3. Introduction • But it took more number of lines of code and more time. • With Validation controls this could be done in couple of minutes.
  • 4. Types of Validation • Client Side Validation: – It means the checking of data format or validation is done at Client Side. – It is done by the browser itself. – The Client Side validation gives faster response to Client.
  • 5. Types of Validation • Server Side Validation: – It means the checking of data format or validation is carried out at Server Side. – Even though the data is checked at client side, the data is again validated at Server Side, so that the attacker or hacker cannot manipulate the data on the browser side.
  • 6. What are Validation Controls? • The Controls that are used to validate the data against some input format are known as Validation Controls. • If the data does not pass the validation, it will display an error message to the user and he would be able to submit the data.
  • 7. Different Types of Validation Controls • RequiredFieldValidator • CompareValidator • CustomValidator • RangeValidator • RegularExpressionValidator • ValidationSummary
  • 8. RequiredFieldValidator Control • The RequiredFieldValidator control is used to make an input control a required field. • With this control, the validation fails if the input value does not change from its initial value. By default, the initial value is an empty string (""). • The basic syntax is given as: – <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="This field can not be blank."> </asp:RequiredFieldValidator>
  • 9. CompareValidator Controls • The CompareValidator control is used to compare the value of one input control to the value of another input control or to a fixed value. • The basic syntax for controls is: – <asp:CompareValidator ID="CompareText" runat="server" ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="Test Does not match" />
  • 10. RangeValidator Controls • The RangeValidator control is used to check that the user enters an input value that falls between two values. • It is possible to check ranges within numbers, dates, and characters. • The basic syntax is given as: – <asp:RangeValidator ID="Validator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Please enter no between 20 to 40." MaximumValue="40" MinimumValue="20“ Type="Integer"></asp:RangeValidator>
  • 11. RegularExpressionValidator Control • The RegularExpressionValidator control is used to ensure that an input value matches a specified pattern. • It is powerful tool which is used to check against specific types of values which may be string, integer, data, mixed etc. • For example: – Input Mobile no in a specific format – To input zip code of 6 digits only. – To input Email address
  • 12. RegularExpressionValidator Symbols Character Description w Any word character (letter, number or underscore) d Any digit D Any character that is not Digit s Any white space character like tab or space S Any non white space character | To specify one of the given choices [ ] To specify a range of character or set of characters [^ ] To specify opposite of specified characters. * To specify zero or more number of characters + To specify one or more number of characters
  • 13. RegularExpressionValidator Symbols Expression Meaning w{10} Allow only 0 character which can be Letter, Number or Underscore w{5,10} Allows character between length 5 to 10 w{5,} Allows characters with minimum length 5 d{5} Allows only 5 digits [M | m | F | f] Allows one of M, m, F or F [A - D] Allows any one between A to D [^A - D]{5} Allows 5 characters except from A to D [A - D]* Allows zero or any no of characters between A to D S{10} Allows 10 non white space characters
  • 14. RegularExpressionValidator Symbols Use Example Zip Code 361002 Mobile No. +91 - 9999999999 Email test@gmail.com Product code B- 2345 Choice Y or y or N or n Symbol d {6} +d{2} - d{10} S+@S+.S+ [A-D] - d{4} [Y | y | N | n]
  • 15. • The syntax can be given as: – <asp:RegularExpressionValidator ControlToValidate="txtbox1" ValidationExpression="d{6}" EnableClientScript="false" ErrorMessage="The zip code must be 5 numeric digits!" runat="server" />
  • 16. CustomValidator Controls • The CustomValidator control allows you to write a method to handle the validation of the value entered. • CustomValidator control allows us to specify our own functions: – Server Side Validation Functions – Client Side Validation Functions
  • 17. CustomValidator Controls • Server side Validation Function: – It is executed on server side. – The name of the server side function is ServerValidate function. – The function name is automatically added after the control name.
  • 18. CustomValidator Controls • Server side Validation Function: – For example: protected void cusCustom_ServerValidate(object o, ServerValidateEventArgs e) { if (e.Value.Length == 8) e.IsValid = true; else e.IsValid = false; }
  • 19. CustomValidator Controls • Server side Validation Function: – It has two main arguments: – Object Source: • Source name of control. – ServerValidateEventArgs e: • It will give us two important properties about the control. – e.Value » This will give us value of control – e.IsValid » It can set to true or false. It depends on the choice of checking.
  • 20. CustomValidator Controls • Client Side Validation Function: – This is used to perform client side validation function name. – It has two property: • ClientValidationFunction • ValidateEmptytext
  • 21. CustomValidator Controls • Client Side Validation Function: <script language="JavaScript"> function validateNumber(oSrc, args) { args.IsValid = (args.Value % 5 == 0); } </script>
  • 22. CustomValidator Controls • Server Side Validate Function will be checked when its value will be submitted to the server. • While Client Side Validate Function will be checked as soon as control loses focus.
  • 23. CustomValidator Controls • The syntax can be given as: – <asp:CustomValidator ControlToValidate="txt1" ClientValidationFunction ="user“ OnServerValidatie=“test_ServerVali” Text="A username must be between 8 and 16 characters!" runat="server"/>
  • 24. ValidationSummary Controls • The ValidationSummary control is used to display a summary of all validation errors occurred in a Web page. • The error message displayed in this control is specified by the ErrorMessage property of each validation control. • If the ErrorMessage property of the validation control is not set, no error message is displayed for that validation control.
  • 25. ValidationSummary Controls • It has four property: – DisplayMode: Mode of displaying all the errors. It can be List, BulletList or single Paragraph. – HeaderText: We can give the header of validation summary. – ShowMessageBox: It is Boolean property which is used to see error list as MessageBox – ShowSummary: It is Boolean property which is used to see error list as Summary.
  • 26. • The syntax can be given as: – <asp:ValidationSummary ID="ValidationSummary1" HeaderText="You must enter a value in the following fields:" ShowMessageBox="true" ShowSummary="false" EnableClientScript="true" runat="server"/>
  • 27. Validation Group • Validation Group is a new feature that was included in ASP.NET 2.0 version. • The validation group helps you to group the controls of a single page into separate groups, so that you can submit each group separately. • Each group will have separate validation controls.
  • 28. Validation Group • When you submit a group of values from a group, only the validation controls which are intended for that group would be executed. • This grouping of controls is achieved in ASP.Net 2.0 by modifying the property called the ValidationGroup property.