Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

Tutorial 6 Creating a Web Form
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Web Database Programming Input Validation. User Input on the Web Web browser built-in mechanisms –HTML Forms HTTP POST method –Hyperlinks HTTP GET method.
Forms cs105. More Interactive web-pages So far what we have seen was to present the information. (Ex: tables. Lists,….). But it is not enough. We want.
JavaScript Forms Form Validation Cookies CGI Programs.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
Forms Describe common uses of forms on web pages
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Chapter 10 Form Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
CST JavaScript Validating Form Data with JavaScript.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
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.
Website Development with PHP and MySQL Saving Data.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
LOGO FORMs in HTML CHAPTER 5 Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC229 Client-Side.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Week 9 - Form Basics Key Concepts 1. 1.Describe common uses of forms on web pages 2.Create forms on web pages using the form, input, textarea, and select.
ITCS373: Internet Technology Lecture 5: More HTML.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Creating Web Page Forms. Introducing Web Forms Web forms collect information from users Web forms include different control elements including: –Input.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Introduction to JavaScript CS101 Introduction to Computing.
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.
HTML Forms a form is a container for input elements on a web page input elements contain data that is sent to the web server for processing.
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
©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.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Creating Web Page Forms COE 201- Computer Proficiency.
HTML Forms.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 6: Creating XHTML Forms Kelly.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Tutorial 6 Creating a Web Form
HTML FORM. Form HTML Forms are used to select different kinds of user input. HTML forms are used to pass data to a server. A form can contain input elements.
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Introducing Forms.
Forms, cont’d.
Presentation transcript:

Form Handling, Validation and Functions

Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers Form controls are grouped inside the element Some common controls: buttons, text boxes, checkboxes, etc.

Form Handling (continued) In order to manipulate data from forms, a server must be equipped with a technology for data handling Some common technologies include ColdFusion, Java Server Pages (JSP), ASP.NET, Common Gateway Interface (CGI), etc.

Form Attributes There are two form attributes action Method This attributes specifies the URL that is intended to receive the data from form elements This attributes specifies the type of HTTP method by which data is sent to the server

Action Attribute This attribute is essential in any form –It indicates the location to which form data will be sent Example: When submitting a form, the location of the Webpage must be specified

Method Attribute There are two common form methods GET POST Data sent by the form is appended to the URL specified in the Action attribute Data sent by the form is not appended to the URL specified in the Action attribute

Method Attribute Examples GET POST Form data Data is transmitted part of the HTTP Request instead of the URL

Form Tags Submit & Reset button tags have two attributes in this example: –TYPE: tells the browser what kind of button to create –VALUE: specifies the message that is to be displayed on the button

Input Form Tags Input tags are placeholders for information data that is transmitted to the action URL Example

Form Example in BlackBerry Assume that we would like to collect user data in a form including: –Name (text box) –BlackBerry device type (drop down menu) – address (text box) –Newsletter option (checkbox) Save the file as FormExample.cfm

Form Example in BlackBerry (continued) HTML code actionmethod input text box drop down menu input text box radio button

Form Example in BlackBerry (continued) Browser output One important item is missing –the “submit” button

Form Example in BlackBerry (continued) updated HTML code submit button

Form Example in BlackBerry (continued)

Collecting Data from Form Elements Now that the form is ready to send data; the URL in the action attribute must be able to collect the values from the form elements The URL then can process the data and return a response message to the user –If you attempt to click on the “Submit my info” button, you will get an error because the action does not exist yet BlackBerry error message

Data Collection from Forms Create a file called “processData.cfm” –Modify the action attribute in the form to this URL To collect values of form variables in ColdFusion, the form variable is used Syntax: Example:

Data Collection from Forms (continued) Action URL code

Data Collection from Forms (continued) You can also use the output command to display the values of more than one variable at once Example

Data Collection

Validating Forms Form validation is sometimes necessary when completing forms –It ensures that users enter data into a field –Check the validity of data entered Three types of form validation –Server-side (using CFML) –Client-side (using JavaScript)

Server-Side CFML Validation These controls are usually hidden –Prebuilt: CFML contains validation hidden fields that are predefined –Example: required data entry Value of the name attribute must match the form control plus the special suffix input type hidden is used value attribute contains the error message

Adding Form Validation to FormExample.cfm Modify FormExample.cfm to validate user input and checks for missing data fields

Adding Form Validation to FormExample.cfm (continued) Browser output BlackBerry

Custom Server-side Form Validation Developers can create their own validation code This type of validation is required at the action URL and not the form URL –i.e. processData.cfm and not FormExample.cfm Requires the use of if conditional statements –

Custom Server-side Form Validation (continued) processData.cfm

Running Custom Server-side validation Browser BlackBerry

Server-side Form Validation: Summary Using the built-in validation may cause BlackBerry devices to “think” of exceptions as server side internal errors –This is due to the way ColdFusion handles exceptions It is recommended in this case to use your own validation code

Client-side Form Validation Using server-side validation may increase the overhead for mobile clients –requires active connections to/from the device User submits the form Server validates the data On errors, send message User checks form data and resubmits etc… Client-side validation is performed within the browsers using built-in JavaScript

Client-side Form Validation (continued) Since mobile devices are limited in memory size, using too many JavaScript validations may consume too much memory Mobile devices, including BlackBerry, have limited browser versions –BlackBerry supports JavaScript 1.1, 1.2, 1.3 and subsets of 1.4 and 1.5 BlackBerry devices must have JavaScript support enabled (default is disabled) in browser configuration

Client-side Form Validation Example To use CFM client-side form validation, one must use CFM controls –i.e.,, etc. Using FormExample.cfm, let’s add client-side validation for the fields firstName and Address Example –

Client-side Form Validation Example (continued) important: You must declare a name attribute for CFM controls, otherwise you will receive an error this will cause a message box to appear

Client-side Form Validation Example (continued) Browser BlackBerry

Client-side Form Validation Regular Expressions Form validation can also use regular expressions The following example defines a valid format for addresses

Client-side Form Validation Regular Expressions (continued) Browser BlackBerry

Functions Function is a piece of code that performs a specific task Format function_name(param 1, param 2,…param n ) Example

Common Built-in Functions Now()returns the system date and time UCase(…)returns the uppercase of a string LCase(…)returns the lowercase of a string Trim(…)removes spaces FileExists(path)checks the existence of a file Compare(str1,str2)compares two strings More functions can be found in

Log In Example Let’s create a form that contains two input text boxes error.cfmwelcome.cfm success failure login.cfm username password check.cfm

Log In Example login.cfm login,cfm

Log In Example check.cfm check,cfm

Log In Example welcome.cfm and error.cfm welcome,cfm error,cfm

Log In Example Output Browser BlackBerry