VALIDATION CONTROLS.  Validation Controls are primarily used to validate, or verify the data entered by user into a web form.  Validation controls attempt.

Slides:



Advertisements
Similar presentations
Tutorial 6 Creating a Web Form
Advertisements

Ch3: Introduction to HTML5 part 2 Dr. Abdullah Almutairi ISC 340 Fall 2014.
Asp.NET Core Vaidation Controls. Slide 2 ASP.NET Validation Controls (Introduction) The ASP.NET validation controls can be used to validate data on the.
web controls  standard controls  validation controls  rich controls.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
ASP.NET Validating user input Validating user input on the client and/or server side 1ASP.NET Validating User Input.
ASP.NET Programming with C# and SQL Server First Edition
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
Chapter 9 – Validating User Input Dr. Stephanos Mavromoustakos.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
JavaScript Form Validation
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Module 7: Validating User Input.
.NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 3. 2 Overview Cookies Validation controls Client and server side validation Validation control examples.
Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital Media.
Creating a Web Site to Gather Data and Conduct Research.
ASP.Net, Web Forms and Web Controls 1 Outline Web Controls Text and Graphics Controls AdRotator Control Validation Controls.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
BIT 285: ( Web) Application Programming Lecture 08: Thursday, January 29, 2015 Data Validation, Using Validators Instructor: Craig Duckett.
Validation and Rich controls 1www.tech.findforinfo.com.
Microsoft Visual Basic 2008 CHAPTER SEVEN Creating Web Applications.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
ASP.NET Event Handlers Database -> Browser ->Shopping Basket Validators.
Using Client-Side Scripts to Enhance Web Applications 1.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
MIS 3200 – Unit 3 What can computers do – Follow a sequence of instructions – Follow different paths of instructions based on decisions – Do things over.
Starting with our inputs, we will add some constraints to enable client-side validation Kuali University: Apply Now Lab 2: Validation and Constraints Lab.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Lesson 12 Adding Validation To The Movie Database.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company ASP.NET Validation Control Presented By : Muhammad Atif Hussain Deputy.
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
Building Applications using ASP.NET and C# / Session 4 / 1 of 15 Session 4.
Session 6: Validating User Input. Outline Overview of User Input Validation Client-Side and Server-Side Validation ASP.NET Validation Controls Using Validation.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 User Input Validating.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Vijayalakshmi G M Validation Controls.
ASP + JavaScript Client and Server scripts. Link 1 function MyClick(){ document.write("MyClick"); } function MyFunction1(){ alert("My Function 1"); }
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Beginning ASP.NET in C# and VB Chapter 9
Tutorial 6 Creating a Web Form
Using Personalization Creating user profiles Retrieving, changing, and saving profile properties Using validation controls Using the Forms Designer.
Validation Controls Assist your users with providing the correct type of input for your application Assist your users with providing the correct type of.
Chapter 9 Validating User Input. Objectives What user input is and why it’s important to validate it What ASP.NET has to offer to aid you in validating.
JavaScript, Sixth Edition
Validation & Rich Controls
Chapter 5 Validating Form Data with JavaScript
© 2016, Mike Murach & Associates, Inc.
Web Application Web Application are programs that can be executed either on a Web server or in a Web browser. An Online store accessed through a browser.
Web Programming– UFCFB Lecture 17
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Unit 27 - Web Server Scripting
12/9/2018 Session 9.1 Calendar and Validation Controls Using Sessions
JavaScript Form Validation
PART 2.
Web Development Using ASP .NET
Asp.net.
MIS 3200 – Unit 2.2 Outline What’s the problem with bad data?
.NET Validation Controls
Validation & Rich Controls
Presentation transcript:

VALIDATION CONTROLS

 Validation Controls are primarily used to validate, or verify the data entered by user into a web form.  Validation controls attempt to fix the existing problems with the validation model.  Though Validation controls are server side objects, they can generate the client side script necessary to notify the user of an error immediately after they submit the form, before the browser contacts the server.  All the validation controls inherit from the base class BaseValidator, so all have a series of common properties and methods.

 These are :- ControlToValidate : The ID of the control that this validator validates. ErrorMessage : This is the message that will be displayed in the validation summary. IsValid : A Boolean value that indicates whether the control specified by ControlToValidate is determined to be valid. Display : It has three possible values : Dynamic, Static and None. Dynamic : means that the space the control uses is’nt reserved for the control. Static : means that the space it uses is always reserved for the control. None : makes the control invisible.

 There are six validation controls :- RequiredFieldValidator CompareValidator RangeValidator RegularExpressionValidator CustomValidator ValidationSummary

RequiredFieldValidator  It is used to make sure that the user enters some information in a field.  This validation control can also be used to prompt message to the user if he or she has left any input field with its default value.  To validate a required entry : Add a RequiredField Validator control to the page & set the following properties : PropertyDescription ControlToValidateThe ID of the control for which the user must provide a value. ErrorMessage, Text, DisplayProperties that specify the text and location of the error or errors that will appear if the user skips the control.

 Add a test in your ASP.NET Web page code to check for validity If Page.IsValid Then e1.Text = “Required Field is filled” Else e1.Text = “Required Field is empty” End If

CompareValidator  It can be used in two ways :-  It can be used to make sure that the user enters identical data in two input fields.  A typical and often used case is password matching.  It can also be used to check for comparisons such as equality, greater than, less than etc.  In addition you can check whether the data entered in the input field is of the datatype as specified by you.  To validate against a specific value.  Add a CompareValidator Control to the page and set the following properties:

PropertyDescription ControlToValidateThe ID of the control for which the user must provide a value. ErrorMessage, Text, Properties that specify the text and location Display of the error or errors that will appear if the user skips the control. ValueToCompareA specified value to compare with ControlToCompareThe name of the control to compare with TypeSpecifies the data type of the values to compare. The types are: Currency,Date,Double,Integer,String OperatorThe type of comparison to perform. The operators are : Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DataTypeCheck  Add a test in your ASP.NET Web page code to check for validity If Page.IsValid Then e1.Text = “CompareValidator is correct” Else e1.Text = “CompareValidator is wrong” End If

RangeValidator  You can use the ASP.NET RangeValidator Control to determine whether a user’s entry falls within a specific range of acceptable values. For eg. between two numbers, between two dates, between two alphabetic characters.  You set the lower and upper bounds of the range as properties of a RangeValidator Control  You must also specify the datatype of the values that the control will validate.  To validate against a range of values : Add a RangeValidator Control to the page and set the following properties : PropertyDescription ControlToValidateThe ID of the control for which the user must provide a value. ErrorMessage, Text, DisplayProperties that specify the text and location of the error or errors that will appear if the user skips the control.

MaximumValueSpecifies the maximum value of the input control MinimumValueSpecifies the minimum value of the input control TypeSpecifies the data type of the values to check. The types are: Currency,Date,Double,Integer,String

RegularExpressionValidator  The RegularExpressionValidator Control confirms that the entry matches a pattern defined by regular expression.  You can check the Validation of the commonly performed formats such as social security numbers, addresses, telephone numbers & postal code.  To validate against a Regular Expression : Add a RegularExpressionValidator control to the page and set the following properties : PropertyDescription ControlToValidateThe ID of the control for which the user must provide a value. ErrorMessage, Text, DisplayProperties that specify the text and location of the error or errors that will appear if the user skips the control.

 Set the pattern to compare to by setting the ValidatationExpression property to a regular expression.  If you want to allow multiple valid patterns, use the bar character(|) to separate expressions.

CustomValidator  If existing ASP.NET validation controls do not suit your needs, you can define a custom function and call it using the CustomValidator Control.  Two validation functions can be performed using Custom validation control : first on the server side and second on the client side.  These functions contain logic defined by you to validate the input fields.  You should perform server side validation even if you use the client side check.  To validate on the server using a custom function : Add a CustomValidator Control to the page and set the following properties PropertyDescription ControlToValidateThe ID of the control for which the user must provide a value. ErrorMessage, Text, DisplayProperties that specify the text and location of the error or errors that will appear if the user skips the control.

Create a server based event handler for the control’s ServerValidate event. This event is called to perform the validation.The method has the signature as follows : Protected Sub CustomValidator1_ServerValidate(ByVal _source as System.Object, ByVal Args as _ System.Web.UI.WebControls.ServerValidateEventArgs)_Handles CustomValidator1.ServerValidate End Sub The source parameter is a reference to the CustomValidation control raising this event. The property args.value will contain the user input to validate. Set args.IsValid to true if the value is valid, otherwise false. Protected Sub TextValidate(……) args.IsValid=(args.Value.Length >=8) End Sub

Bind the event handler to the method using code such as the following : <asp:customValidator id=“customValidator1” runat=“server” onServerValidate=“TextValidate” ControlToValidate=“TextBox1” ErrorMessage=“Text must be 8 or more characters”/>  Add a test in your ASP.NET Web page to check for validity : To create custom validation logic on the client function validateLength(Osrc,args) { if(args.Value.length > 8) { args.IsValid=true } else { args.IsValid=false } Set ClientValidationFunction property to the name of the function that performs the client-side validation.

ValidatonSummary  Displays a summary of all validation errors inline on a web page, in a message box or both.  The ValidationSummary Control is used to summarize the error messages from all validators on a web page in a single location.  You can summarize the error messages from a group of validators on a web page by assigning the ValidationSummary Control to a validation group by setting the ValidationGroup property.  The summary can be displayed as a list, as a bulleted list, or as a single paragraph, based on the DisplayMode property.  The Summary can be displayed on the web page and in a message box by setting the ShowSummary and ShowMessageBox properties respectively.