HTML5 Level II Session III

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

Tutorial 6 Creating a Web Form
Ch3: Introduction to HTML5 part 2 Dr. Abdullah Almutairi ISC 340 Fall 2014.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Chapter 6 Basic forms 1. Forms and query string 2 form : a group of user input (UI) controls that accepts information from the user and sends the information.
CHAPTER 30 THE HTML 5 FORMS PROCESSING. LEARNING OBJECTIVES What the three form elements are How to use the HTML 5 tag to specify a list of words’ form.
JavaScript Forms Form Validation Cookies CGI Programs.
HTML Tables and Forms Creating Web Pages with HTML CIS 133 Web Programming Concepts 1.
  Just another way to collect pieces together (like div, section)  Anything can be in there  Formatting just like all other elements.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
Chapter 10 Form Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
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 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.
HTML 5 Tutorial Chapter 9 Form Attributes. New Form Attributes HTML5 has several new elements and attributes for forms. New form attributes : autocomplete.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
JavaScript Form Validation
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 07: Forms - Spring 2011.
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.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Neal Stublen Improvements  New form elements  Assist with validation  Consistency across sites  Changes reduce the need for common.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
CHAP 3. FORM API.  Forms should still be encapsulated in a element where the basic submission attributes are set.  Forms still send the values of the.
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.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
HTML 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.
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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
Forms Collecting Data CSS Class 5. Forms Create a form Add text box Add labels Add check boxes and radio buttons Build a drop-down list Group drop-down.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Web Technologies Lecture 3 Web forms. HTML5 forms A component of a webpage that has form controls – Text fields – Buttons – Checkboxes – Range controls.
+ FORMS HTML forms are used to pass data to a server. begins and ends a form Forms are made up of input elements Every input element has a name and value.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
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.
HTML5 Forms Forms are used to capture user input …
HTML Forms.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 Web Engineering Forms Lecture 05. FORMS Its how HTML does interactivity. There are quite new feature in HTML5. But the fundamental idea does not change.
CIS 228 The Internet 12/6/11 Forms and Validation.
Tutorial 6 Creating a Web Form
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,
Session I How to Work with Forms Chapter 11 - How to Work with Formswww.profburnett.com.
INTRODUCTION TO HTML5 HTML5 Form Input. Create a Number Input Type  You can use the number input type to restrict input fields to numeric values only.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
JavaScript, Sixth Edition
Chapter 5 Validating Form Data with JavaScript
HTML 5.
>> Introduction to HTML: Forms
In this session, you will learn to:
Objectives Design a form Create a form Create text fields
Web Programming– UFCFB Lecture 17
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Objectives Explore web forms Work with form servers
Web Development & Design Foundations with H T M L 5
FORM OBJECT When creating an interactive web site for the Internet it is necessary to capture user input and process this input. Based on the result of.
Forms, cont’d.
Web Development & Design Foundations with H T M L 5
Session IV Chapter 10 – How to Work with Forms and Data Validation
Form Validation, Part 2 (with jQuery, HTML5, and CSS)
Basics of Web Design Chapter 10 Form Basics Key Concepts
HTML5 - 2 Forms, Frames, Graphics.
Form Validation (with jQuery, HTML5, and CSS)
Session III Chapter 10 – How to Work with Forms and Data Validation
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

HTML5 Level II Session III Chapter 10 – How to Work with Forms and Data Validation www.profburnett.com

Class Outline Forms and Form Controls jQuery Form Selectors jQuery Event Methods for Forms jQuery Form Validation jQuery Date Picker jQuery Improved Buttons jQuery Autocompletion jQuery Form Builder 12/1/2018 Copyright © Carl M. Burnett

Forms – Why are they Important?

Form Element Attributes Description name A name the can be referred to by client-side or server-side code. action The URL of the file that will process the data in the form. method Specifies the HTTP method (GET or POST) to be used when submitting the form data. “get” is default.

HTML5 controls for input data Input Type Example Description email <input type="email"> used for input fields that should contain an e-mail address url <input type="url"> used for input fields that should contain a URL address tel <input type="tel"> used for input fields that should contain a telephone number. number <input type="number"> defines a numeric input field date <input type="date"> used for input fields that should contain a date time <input type="time"> allows the user to select a time (no time zone) color <input type="color"> used for input fields that should contain a color

HTML5 controls for input data Input Type Example Description datetime-local <input type="datetime-local"> specifies a date and time input field, with no time zone month <input type="month"> allows the user to select a month and year. search <input type="search"> used for search fields (a search field behaves like a regular text field). week <input type="week"> allows the user to select a week and year. range <input type="range"> defines a control for entering a number whose exact value is not important (like a slider control). Default range is 0 to 100. However, you can set restrictions on what numbers are accepted with the min, max, and step attributes

The basic HTML5 attributes for working with forms Description autofocus specifies that the input field should automatically get focus when the page loads. placeholder specifies a hint that describes the expected value of an input field (a sample value or a short description of the format)

The HTML5 attributes for data validation Tag Description autocomplete <input> specifies whether a form or input field should have autocomplete on or off. pattern (regexp) specifies a regular expression that the <input> element's value is checked against. title required specifies that an input field must be filled out before submitting the form novalidate <form> specifies that the form data should not be validated when submitted.

CSS3 pseudo-classes selectors Example Description :required input:required Selects input elements with the "required" attribute specified :valid input:valid Selects all input elements with a valid value :invalid input:invalid Selects all input elements with an invalid value

jQuery Form Selectors Selector Example Description :input $(':input') Selects all input, textarea, select, and button elements. In other words, it selects all form elements. :text $(':text') Selects all text fields. :password $(':password') Selects all password fields. :radio $(':radio') Selects all radio buttons. :checkbox $(':checkbox') Selects all checkboxes. :submit $(':submit') Selects all submit buttons. :image $(':image') Selects all image buttons. :reset $(':reset') Selects all reset buttons.

jQuery Form Selectors jQuery Selector Tester Selector Example Description :button $(':button') Selects all fields with type button. :file $(':file') Selects all file fields (used for uploading a file). :hidden $(':hidden') Selects all hidden fields. :enabled $(':enabled') Selects all enabled input elements :checked $(':checked') Selects all checked input elements :selected $(':selected') Selects all selected input elements jQuery Selector Tester

The jQuery methods for getting, setting, and trimming control values Description val() Gets the value attribute of the selected elements (for form elements) val(value) Sets the value attribute of the selected elements (for form elements) trim() Removes all the spaces as the start and end of the string (for form elements)

The jQuery methods for triggering events Description focus() Moves the focus to the selected element and triggers the focus event blur() Removes the focus to the selected element and triggers the blur event change() Triggers the change event select() Triggers the select event submit() Triggers the submit event for a form

The jQuery event methods for forms Description focus(handler) The handler runs when the focus moves to the selected element blur(handler) The handler runs when the focus leaves the selected element change(handler) The handler runs when the value in the selected element is changed select(handler) The handler runs when the user selects text in a text or text area box submit(handler) The handler runs when the a submit button is clicked in a form

jQuery Form Validation Rules Description required The field won’t be submitted unless this field is filled out, checked, or selected. date Information must be in the format MM/DD/YYYY. For example, 10/30/2014 is considered valid, but 10-30-2014 is not. url Must be a full, valid web address like http://www.chia-vet.com. Partial URLs like www.chia-vet.com or chia-vet.com (http://chia-vet. com) are considered invalid. email Must be formatted like an email address: bob@chia-vet.com. This class doesn’t actually check to make sure the email address is real, so someone could still enter nobody@noplace.com and the field would pass validation. number Must be a number like 32 or 102.50 or even –145.5555. However, the input can’t include any symbols, so $45.00 and 100,000 are invalid. digits Can only include positive integers. So 1, 20, 12333 are valid, but 10.33 and –12 are not valid. creditcard Must be a validly formatted credit card number.

Forms with jQuery UI Widgets Date Picker Improved Buttons Autocompletion

Picking Dates with Style Attach jQuery UI’s CSS and JavaScript files to your web page. Add a form to a page, and include a text <input> field for capturing a date. Add jQuery’s $(document).ready() function to your page Use jQuery to select the input element(s) and call the datepicker() function.

Setting Date Picker Properties changeMonth changeYear dateFormat monthNames numberOfMonths maxDate minDate yearRange Basic Example

Stylish Select Menus Attach jQuery UI’s CSS and JavaScript files to your web page. Add a form to a page, and include a text <input> field for capturing a date. Add jQuery’s $(document).ready() function to your page Use jQuery to select the menu and call the selectmenu() function: Pass an object literal to the selectmenu() function with a width property.

Setting Select Menu Properties width icons position

Styling Buttons Attach jQuery UI’s CSS and JavaScript files to your web page. Add a button to the page. It can be either a reset, submit, or input button or <button> element. Add jQuery’s $(document).ready() function to your page Use jQuery to select the button and call the button function Customizing Buttons Stylized Form

Providing Hints with Autocomplete Attach jQuery UI’s CSS and JavaScript files to your web page. Add a form to the page, and include a text input field Add jQuery’s $(document).ready() function to your page Use jQuery to select the text field and call the autocomplete function.

Using Arrays for Autocomplete var airports = [ 'Aberdeen Regional Airport, Aberdeen, South Dakota', 'Abilene Regional Airport, Abilene, Texas’, 'Abraham Lincoln Capital Airport, Springfield, Illinois’, 'Adak Airport, Adak Island, Alaska’, 'Adirondack Regional Airport, Saranca Lake, New York’ ]; // lots more airports would go in here

Using Separate Labels and Values var airports = [ { label : 'Aberdeen Regional Airport, Aberdeen, South Dakota', value : 'ABR' }, label : 'Abilene Regional Airport, Abilene, Texas', value : 'ABI' { label : 'Abraham Lincoln Capital Airport, Springfield, Illinois', value : 'SPI' label : 'Adak Airport, Adak Island, Alaska', value : 'ADK' label : 'Adirondack Regional Airport, Saranca Lake, New York', value : 'SLK' }

Getting Autocomplete Data from the Server A visitor begins typing into a text field. The visitor’s input is sent to the server. Using Ajax, the browser sends data to the server and waits for a response. In this case, the browser sends the text the visitor has typed so far. The server sends back an array of terms that match what the visitor has typed so far. The server provides a list of matching terms. Usually, this is accomplished using server-side programming that searches a database, gets results, and formats those results into an array that’s sent back to the browser. The list of matching terms appears in the autocomplete menu. Autocomplete Form

jQuery Form https://www.jqueryform.com/ jQuery Form Builder 12 Form Validation Date Picker Picture Choice Form Logic Google Friendly Personalized Email Messages

Student Exercise 1 Complete Chapter 10-1 Validate with JavaScript exercise on page 305 Create link to your Web4Students Webpage. Preview updated Web4Students Webpage. Post Chapter 10 Exercise and update Web4Students Webpage to Live site.

Student Exercise 2 Complete jQuery UI Form Widget Tutorial. (refer to handout) Create link to your Web4Students Webpage. Preview updated Web4Students Webpage. Post jQuery UI Form Widget Tutorial Exercise and update Web4Students Webpage to Live site.

Class Review Forms and Form Controls jQuery Form Selectors jQuery Event Methods for Forms jQuery Form Validation jQuery Date Picker jQuery Improved Buttons jQuery Autocompletion jQuery Form Builder Next – Chapter 11 How to use jQuery plugins and jQuery UI Widgets 12/1/2018 Copyright © Carl M. Burnett