
Understanding Validation Controls in Web Development
Learn how validation controls are used to ensure data accuracy in web applications, covering common properties, techniques, and advanced controls. Explore examples like RequiredFieldValidator, CompareValidator, and RangeValidator to enhance user input validation.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
7. Validation Controls [231-247] Name : Ankita Parulekar Presentation ID: 13 CSCI 5633
outline Introduction How to use validation control Common validation properties Validation techniques Advanced validation controls
Validation control A Validation control is used to validate the data of an input control. For example, error message will be displayed directly to the right of the text box, if it is not valid. We can use the validation controls with any of web server or HTML server input control. Validator is associated with single input control, but we can use two or more validators with same input control.
Required field validator <asp:RequiredFieldValidator runat="server" id="reqName" controltovalidate="txtName" errormessage="Please enter your name!" />
Compare Validator <asp:CompareValidator runat="server" id="cmpPassword" controltovalidate= txtPassword" controltocompare= txtRePassword" type= Password" errormessage= Confirm password does not match the password" />
Range Validator <asp:RangeValidator runat="server" id="rngDate" controltovalidate="txtDate" type="Date" minimumvalue="01-01-2006" maximumvalue="31-12-2006" errormessage="Please enter a valid date within 2006!" />
Validation Techniques Validation summary control: Summarize all the errors on a page. Validation groups: Specifies which group should be validated when a page is posted.
Validation Summary Control <asp:ValidationSummary DisplayMode="ValidationSummaryDisplayMode" />
Validation Groups <asp:TextBox ID="TextBox1" Runat="server ValidationGroup="First"></asp:TextBox>
Advanced Validation Control We can create our own validation routines. We can use Regular Expression validator to make sure that the input data matches to a particular pattern.
Advanced validation control <asp:RegularExpressionValidator ID="regexpName" runat="server" ErrorMessage="This expression does not validate." ControlToValidate="txtName" ValidationExpression="^[a-zA-Z'.\s]{1,40}$" />