Module 7: Validating User Input.

Slides:



Advertisements
Similar presentations
Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.
Advertisements

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.
DT211/3 Internet Application Development JSP: Processing User input.
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.
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 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
WEB FORM DESIGN. Creating forms for a web page For your web project you have to design a form for inclusion on your web site (the form information should.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
.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.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Validation Controls. Validation Server Controls These are a special type of Web server control. They significantly reduce some of the work involved in.
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.
Christopher M. Pascucci.NET Programming: Forms & Controls.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 3. 2 Overview Cookies Validation controls Client and server side validation Validation control examples.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital Media.
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.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Lesson 12 Adding Validation To The Movie Database.
Module 4: Creating a Microsoft ASP.NET Web Form. Overview Creating Web Forms Using Server Controls.
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.
VALIDATION CONTROLS.  Validation Controls are primarily used to validate, or verify the data entered by user into a web form.  Validation controls attempt.
Chapter 4: Working with ASP.NET Server Controls OUTLINE  What ASP.NET Server Controls are  How the ASP.NET run time processes the server controls on.
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.
Chapter 9 進階 Web 控制項. 資料驗證 Web 控制項 RequireFieldValidator RequireFieldValidator
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.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
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.
Validation & Rich Controls
Validation Controls, User Controls, Master Pages
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
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
MIS 3200 – Unit 2.2 Outline What’s the problem with bad data?
Server Controls Validation Controls
.NET Validation Controls
Validation & Rich Controls
Presentation transcript:

Module 7: Validating User Input

Overview Overview of User Input Validation Using Validation Controls Page Validation

Lesson: Overview of User Input Validation What Is Input Validation? Client-Side and Server-Side Validation ASP.NET Validation Controls

What Is Input Validation? Def : A process of verifying that a user’s input on a web form matches the expected data value, range or format. Works by comparing user input against a predetermined input format. Verifies that a control value is correctly entered by the user Blocks the processing of a page until all controls are valid Avoids spoofing or the addition of malicious code

Client-Side and Server-Side Validation User Enters Data ASP.NET can create both client-side and server-side validation Client-side validation Dependent on browser version Instant feedback Reduces postback cycles Uses JavaScript and DHTML Server-side validation Repeats all client-side validation Can validate against stored data Server side validation control Error Message Valid? No Client Yes Server Valid? No Yes Web Application Processed

ASP.NET Validation Controls ASP.NET provides validation controls to: Compare values – Compares an input control to another input control. Eg: Password verification fields.(CompareValidator) Compare to a custom formula – Allows you to write your own code to create the validation expression. ( CustomValidator) Compare to a range – Verifies that the user input is between two values or the values of other input controls. ( RangeValidator ) Compare to a regular expression pattern – Verifies that the entry matches a pattern that has been defined by a regular expression. ( RegularExpressionValidator )

ASP.NET Validation Controls Require user input – checks whether a value has been entered on the control. ( RequiredFieldValidator ) Summarize the validation controls on a page – Display a summary of all of the validation errors on the page. Typically placed naer the Submit button to provide immediate feedback on the page input status. ( ValidationSummary )

Lesson: Using Validation Controls Adding Validation Controls to a Web Form Positioning Validation Controls on a Web Form Combining Validation Controls Input Validation Controls Using the RegularExpressionValidator Control Using the CustomValidator Control

Adding Validation Controls to a Web Form Add a validation control Select the input control to validate Set validation properties <asp:TextBox id="txtName" runat="server" /> <asp:Type_of_Validator id="Validator_id" runat="server" ControlToValidate="txtName" ErrorMessage="Message_for_error_summary" Display="static|dynamic|none" Text="Text_to_display_by_input_control"> </asp:Type_of_Validator>

Positioning Validation Controls on a Web Form Create error messages Select display mode Static: fixed layout for the error page Dynamic Enables validation controls to render in the page as part of the text flow

Combining Validation Controls Can have multiple validation controls on a single input control Only the RequiredFieldValidator checks empty controls

Input Validation Controls RequiredFieldValidator InitialValue CompareValidator ValueToCompare or ControlToCompare Type Operator RangeValidator MinimumValue MaximumValue Code Examples

Using the RegularExpressionValidator Control Used when input must conform to a pre-defined pattern Visual Studio .NET includes patterns for: Telephone numbers Postal codes E-mail addresses <asp:RegularExpressionValidator … ControlToValidate="US_PhoneNumber"… ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4} " …>*</asp:RegularExpressionValidator > Code Example

Demonstration: Using Validation Controls Create an ASP.NET Web Form with TextBox and Button controls Add a RequiredFieldValidator control Add a RangeValidator control Add a RegularExpressionValidator control

Using the CustomValidator Control Can validate on client-side, server-side, or both ClientValidationFunction OnServerValidate Validate with: Formula Data COM objects Web Service Code Example

Demonstration: Using the CustomValidator Control Add a CustomValidator control Write the server-side code Write the client-side script Test the result

Lesson: Page Validation Using the Page.IsValid Property ( Server-side verification ) Using the ValidationSummary Control ( Client-side verification ) Demonstration: Using the Page.IsValid Property and the ValidationSummary Control .NET enables you to verify that all of the controls on a page are valid before the controls perform some action. The verification of validity can be conducted on either client or server, depending on the browser being used.

Using the Page.IsValid Property Polls all validation controls Sub cmdSubmit_Click(s As Object, e As EventArgs) If Page.IsValid Then Message.Text = "Page is valid!" ' Perform database updates or other logic here End If End Sub private void cmdSubmit_Click(object s, System.EventArgs e) { if (Page.IsValid) { Message.Text = "Page is Valid!"; // Perform database updates or other logic here }

Using the ValidationSummary Control Collects error messages from all validation controls on the page Can display text and error messages Use Text="*" to indicate the location of the error <asp:ValidationSummary id="valSummary" runat="server" HeaderText="These errors were found:" ShowSummary="True" DisplayMode="List"/>

Review Overview of User Input Validation Using Validation Controls Page Validation

Exercise For the following questions, you will select the type of validation control(s) that should be used for each scenario. The types of validation controls available for a Web Form include: CompareValidator CustomValidator RangeValidator RegularExpressionValidator RequiredFieldValidator ValidationSummary Given the following user input fields, what kind of validation control(s) would you use? 1. The user‘s age.

Exercise (cont.) The user‘s telephone number. The user‘s password, which is entered twice. Whether an entered number is prime. Whether all of the fields in a form are correctly filled in. Whether the date format is correct. Whether a new employee‘s requested e-mail address matches the company policy.

~ End of Slides ~