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.

Slides:



Advertisements
Similar presentations
23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
Advertisements

24-Aug-14 HTML Forms. 2 What are forms? is just another kind of HTML tag HTML forms are used to create (rather primitive) GUIs on Web pages Usually the.
1 Topic 6 Processing Form Input. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction Form.
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
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.
Lesson 3 HTML Forms Handling. the Form object Tag : Properties: –action - action attribute of tag –elements[ ] - creeated from like named form elements.
JavaScript Forms Form Validation Cookies CGI Programs.
USER INTERACTIONS: FORMS
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Working with Forms in JavaScript (NON-audio version) © Dr. David C. Gibbs
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
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.
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
Client-Side programming with JavaScript 3
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript forms.
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.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
Jquery IS JQuery Jquery Example of mouseover event that shows a submenu when menu selected: $(‘#menu’).mouseover(function() { $(‘#submenu’).show();
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
JavaScript - Document Object Model. Bhawna Mallick 2 Unit Plan What is DOM and its use? Hierarchy of DOM objects. Reflection of these objects in an HTML.
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 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.
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.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Copyright ©2005  Department of Computer & Information Science Introducing DHTML & DOM: JavaScript & Forms.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
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.
Using Client-Side Scripts to Enhance Web Applications 1.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
LOGO FORMs in HTML CHAPTER 5 Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC229 Client-Side.
1 Review of Form Elements. 2 The tag Used in between tags.  Form elements(text control, buttons, etc.. ) goes here. OR  Form elements(text control,
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.
Select (drop-down list) Inputs. Insert/Form/List Menu.
The Web Wizard’s Guide To JavaScript Chapter 3 Working with Forms.
Form Components and Elements
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Unit 10 – JavaScript Validation Instructor: Brent Presley.
Unit 2 — The Exciting World of JavaScript Lesson 7 — Creating Forms with JavaScript.
Week 10: HTML Forms HNDIT11062 – Web Development.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
JavaScript Arrays, Functions, and Forms George Mason University.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
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.
CIS 228 The Internet 12/6/11 Forms and Validation.
HTML Elements: Forms and Controls Chapter 9 B. Ramamurthy.
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.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Methods and Object Information. Some Document Methods.
Chapter 5 Validating Form Data with JavaScript
In this session, you will learn to:
Web Programming– UFCFB Lecture 17
Conditions and Ifs BIS1523 – Lecture 8.
The Web Wizard’s Guide To JavaScript
JavaScript and Forms Kevin Harville.
Presentation transcript:

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 reset submit Event Handlers onReset onSubmit Usually a call to a validate action Simulates the work of the submit button There are a series of element objects which exist in the form.

3 Form Example A real example---the lab error form—with some validationthe lab error form

4 Form Elements Button checkbox FileupLoad Hidden password radio reset Submit text textarea Select-one select-multiple allows more than one in the list to be checked

5 Button Object Properties name value Method click Event handlet onClick Example

6 Submit Object Properties Name Value Methods click Event Handler onClick () Example

7 Reset Object Properties Name Value Method click Event Handler onClick Example

8 Form Elements Array You may reference the items in a form by the formname.elements[n] where n is the input area defined on the form. The numbering starts at 0--so the first input parameter is the same as formname.elements[0].

9 Form Processing Validation CSD 340 McCoey

10 JS Functions to validate form elements JS functions can be used to validate information in a form based on an onclick event. You can use the value attribute of the form element to validate the information. If the information is valid, then the function returns a true. If the information is invalid, the function should tell the user, point to the invalid entry and return a false.

11 JS Function Arguments You can use a general JS function and customize it to change the process based on specific information. To do this you need to add a set of arguments to the function definition. Arguments act as place holders during the general process definition. When the function is called, you pass the actual values to the function.

12 General format function functionname (argumentlist) Then when you call the function, you supply the specific set of variables in the call function functioname (valuelist)

13 Example of JS arguments If you define a JS function definition to calculate a tax amount using the following definition for the function. The function has two arguments in the definition—total and rate. function tax (total, rate) { var tax_amt; tax_amt = total * rate; return tax_amt; }

14 JS Functions Now you want to call the function and send it specific values to use in the calculation. Yo want the results from the calculation to be returned. So assume you have a form taxform and you have a textbox called taxAmt. Then the call might look like document.taxform.taxAmt = tax(129.28,0.1); The result of the calculation is held in the variable tax_amt in the function and the return statement in the function passes the result back to the form.

15 Example of using JS to process a form entry Assume form name is request, and form field is a text field with name of entry. Assume you want to see if user entered any value. Assume the validate function is called form_check. Assume that if the form is valid, you wish to call a server application. If they did not enter any data, display an alert and put them back to the entry. The onsubmit action would be onsubmit = “return form_check ();”

16 JS Function coding for form entry validation function form_check () { if (document.request.entry.value == "") { alert ("You must fill in the entry field"); document.request.entry.focus(); return (false); } else { return (true); }

17 Validating String formats Javascript has a string object included. You may use the string object to check a format. For example if you are validating an and it needs to have you may use the string object to check if is present. You may extend the validation to be sure the number of characters after is a maximum of 3 (for the correct format).

18 String Object stringname.toLowerCase stringname.toUpperCase stringname.indexOf(“char”, n) Returns the start of position of where the character string begins in the entire string.

19 String Object--more stringname.lastIndexof(“char”,n) Searches the string for the set of characters in the string. Returns the last position of the string. stringname.substring(start,stop) Returns a subset of the given string in the start, stop position including the indicated positions.

20 Checking the function valid ( ) { invalidChars = " /:,;" if ( == "") {return false} for (i=0; i<invalidChars.length; i++) { badChar = invalidChars.charAt(i) if ( .indexOf(badChar,0) > -1) {return false} } atPos = if (atPos == -1) {return false} if > -1) {return false} periodPos = .indexOf(".",atPos) if (periodPos == -1) {return false} if (periodPos+3 > .length) {return false} return true}