Unit 2 — The Exciting World of JavaScript Lesson 7 — Creating Forms with JavaScript.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

The Web Wizards Guide To JavaScript Chapter 3 Working with Forms.
Murach’s JavaScript, C6© 2009, Mike Murach & Associates, Inc.Slide 1.
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
FORMs Lesson TBE 540. Prerequisites Before beginning this lesson, the learner must be able to… –Create basic web pages using a text editor and/or a web.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
Tutorial 14 Working with Forms and Regular Expressions.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Working with Forms in JavaScript (NON-audio version) © Dr. David C. Gibbs
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Lesson 8 Creating Forms with JavaScript
CST JavaScript Validating Form Data with JavaScript.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
JavaScript Form Validation
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.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
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.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
JavaScript Lecture 6 Rachel A Ober
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 3.
G053 - Lecture 16 Validating Forms Mr C Johnston ICT Teacher
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
1 Forms and Form elements CSD 340 McCoey. 2 Form Object Properties action Usually a call to a server elements encoding method post or get target Methods.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
JavaScript - A Web Script Language Fred Durao
Button and Textbox. Input  Input objects are used to obtain input from the user viewing the webpage. They allow the user to interact with the Web. 
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
The Web Wizard’s Guide To JavaScript Chapter 3 Working with Forms.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
The Web Wizard’s Guide To JavaScript Chapter 3 Working with Forms.
Unit 10 – JavaScript Validation Instructor: Brent Presley.
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.
HTML5 Forms Forms are used to capture user input …
HTML FORMS The TEXT Object Presented By: Ankit Gupta.
Lesson 16. Practical Application 1 We can take advantage of JavaScript and the DOM, to set up a form so that the first text box of a form automatically.
FORM VALIDATION (Java Script ). Required Fields A required field in a form is a field that MUST have at least some content before the form will be processed.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
JAVASCRIPT A quick review. True False ■The DOM is a standardized way of referring to parts of a Web page. ■TRUE ■In the DOM, attributes have their own.
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
JavaScript, Sixth Edition
Chapter 5 Validating Form Data with JavaScript
CHAPTER 10 JAVA SCRIPT.
Topics Graphical User Interfaces Using the tkinter Module
How to Write Web Forms By Mimi Opkins.
Web Programming– UFCFB Lecture 17
Microsoft Visual Basic 2005 BASICS
Event Driven Programming & User Defined Functions
The Web Wizard’s Guide To JavaScript
© 2015, Mike Murach & Associates, Inc.
Chapter 6 Event-Driven Pages
How to organize and document your classes
Murach's JavaScript and jQuery (3rd Ed.)
.NET Validation Controls
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

Unit 2 — The Exciting World of JavaScript Lesson 7 — Creating Forms with JavaScript

The Exciting World of JavaScript 2 Objectives Understand the purpose and usage of JavaScript input controls. Understand the benefits of data validation. Create an HTML form. Enhance the functionality of HTML forms with JavaScript.

The Exciting World of JavaScript 3 Making HTML Forms More Functional Controls/components: Interactive objects with a JavaScript form. Controls or components must be given a name so they can be referenced within JavaScript code. Data validation: The process of checking user input data to make sure it is complete and accurate.

The Exciting World of JavaScript 4 Making HTML Forms More Functional (cont.) Name: Small Pepperoni

The Exciting World of JavaScript 5 Making the Submit Order Button Functional No. 1: Write a doSubmit() function. function doSubmit() { alert("Your pizza order has been submitted."); return; }

The Exciting World of JavaScript 6 Making the Submit Order Button Functional (cont.) No. 2: Describe the event.

The Exciting World of JavaScript 7 Making the Clear Entries Button Functional function doClear() { document.PizzaForm.customer.value = ""; document.PizzaForm.address.value = ""; document.PizzaForm.city.value = ""; document.PizzaForm.state.value = ""; document.PizzaForm.zip.value = ""; document.PizzaForm.phone.value = ""; document.PizzaForm.size[0].checked = false; document.PizzaForm.size[1].checked = false; document.PizzaForm.size[2].checked = false; document.PizzaForm.toppings[0].checked = false; document.PizzaForm.toppings[1].checked = false; document.PizzaForm.toppings[2].checked = false; document.PizzaForm.toppings[3].checked = false; document.PizzaForm.toppings[4].checked = false; document.PizzaForm.toppings[5].checked = false; return; } No. 1: Write a doClear() function.

The Exciting World of JavaScript 8 Making the Clear Entries Button Functional (cont.) No. 2: Reference the text control objects. document.PizzaForm.customer.value = "" The name customer is an element within the FORM object named PizzaForm. This is contained in the document object. Clear the value stored in that text field by assigning an empty string ("").

The Exciting World of JavaScript 9 Making the Clear Entries Button Functional (cont.) No. 3: Describe the event. <INPUT TYPE="BUTTON" VALUE="Clear Entries" onClick="doClear()">

The Exciting World of JavaScript 10 Validating Text Fields Validation: Programmer checks to make sure that a form has no missing data using a validateText() function. This takes an if statement followed by an alert message.

The Exciting World of JavaScript 11 Validating Text Fields (cont.) The doSubmit() function looks for text. With no text, an alert is called. function doSubmit() { if (validateText() == false) { alert("Required data missing in Step 1"); return; } alert("Your pizza order has been submitted."); return; }

The Exciting World of JavaScript 12 Validating Text Fields (cont.) The doSubmit() function calls an alert when the text fields are empty.

The Exciting World of JavaScript 13 Validating Radio Buttons Validation is also important for Radio Buttons. Customers need to be alerted to select the size of their pizza!

The Exciting World of JavaScript 14 Validating Radio Buttons (cont.) No 1: Alter the doSubmit() function to check the object’s value property. function doSubmit() { if (validateRadio() == false) { alert("Required data missing in Step 2"); return; } alert("Your pizza order has been submitted."); return; }

The Exciting World of JavaScript 15 Validating Radio Buttons (cont.) No. 2: Write the validateRadio() function. function validateRadio() { if (document.PizzaForm.size[0].checked) return true; if (document.PizzaForm.size[1].checked) return true; if (document.PizzaForm.size[2].checked) return true; return false; }

The Exciting World of JavaScript 16 Validating Radio Buttons (cont.) No. 3: The doSubmit() function now checks both the text boxes and the radio buttons for data. An alert appears when a radio button is not selected.

The Exciting World of JavaScript 17 Summary You can understand the purpose of JavaScript input controls. You can use JavaScript input controls. You can understand the benefits of data validation. You can create an HTML form that will accept JavaScript code. You can enhance HTML forms with JavaScript.