Form Validation, Part 2 (with jQuery, HTML5, and CSS)

Slides:



Advertisements
Similar presentations
Tutorial 6 Creating a Web Form
Advertisements

WEB DESIGN – SEC 4-11 PART OR ALL OF THIS LESSON WAS ADAPTED FROM THE UNIVERSITY OF WASHINGTON’S “ WEB DESIGN & DEVELOPMENT I ” COURSE MATERIALS PSEUDO-CLASS.
Ch3: Introduction to HTML5 part 2 Dr. Abdullah Almutairi ISC 340 Fall 2014.
  Just another way to collect pieces together (like div, section)  Anything can be in there  Formatting just like all other elements.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
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.
>> More on CSS Selectors. Pre-requisite Open the file called sample.txt Copy the all the text from the file Open your browser and go to codepen.io Paste.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
JavaScript JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user.
Tutorial 6 Creating a Web Form
Cascading Style Sheets Part 1 1 IT 130 – Internet and the Web.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
PDO Database Connections
Introduction to.
Form Data (part 2) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Using JavaScript to Show an Alert
W3C Web standards and Recommendations
jQuery – Form Validation
Tutorial 6 Topic: jQuery and jQuery Mobile Li Xu
PDO Database Connections
JavaScript Forms Adding User Input.
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
Introduction to JavaScript
Objectives Explore web forms Work with form servers
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
A second look at JavaScript
Getting started with jQuery
PDO Database Connections
>> Dynamic CSS Selectors
HTML5 Level II Session III
PDO Database Connections
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
Class07 PHP: loops MIS 3501 Jeremy Shafer Department of MIS
Session IV Chapter 10 – How to Work with Forms and Data Validation
HTML and CSS MIS 2402 Jeremy Shafer Department of MIS
Sending a text message (and more)
Form Validation (with jQuery, HTML5, and CSS)
JavaScript and the DOM MIS 2402 Jeremy Shafer Department of MIS
Numbers, strings and dates in JavaScript
MIS JavaScript and API Workshop (Part 3)
Introduction to AJAX and JSON
An Introduction to Animation
MIS JavaScript and API Workshop (Part 2)
SEEM4570 Tutorial 5: jQuery + jQuery Mobile
An Introduction to JavaScript
Getting started with jQuery
An introduction to jQuery
JavaScript objects, functions, and events
Introduction to JavaScript
An introduction to jQuery
MVC – Model View Controller
Introduction to MIS2402 MIS MIS2402 Jeremy Shafer Department of MIS
Getting started with jQuery
An introduction to jQuery
Introduction to AJAX and JSON
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Form Validation (with jQuery, HTML5, and CSS)
HTML MIS 2402 Jeremy Shafer Department of MIS Fox School of Business
Session III Chapter 10 – How to Work with Forms and Data Validation
Sending a text message (and more)
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Single Page Architecture (SPA)
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

Form Validation, Part 2 (with jQuery, HTML5, and CSS) Jeremy Shafer Department of MIS Fox School of Business Temple University

Recall from last time… Where does our JavaScript/jQuery code run? Where does data validation need to take place? What has been our focus in this course? THE POINT IS: Today we are only focusing on half of what is needed for effective validation of user-provided data. We are focusing on the client-side half. This whole course focuses on just the client side of application development. Server-side resources are explored in MIS3502.

Options for form (data) validation #2. HTML5 added new controls and attributes intended to simplify form validation. It is taking the major browsers some time to catch up to the specification and support them all. We will focus on the most widely supported options. #3. CSS – all on its own – doesn’t provide form validation. But CSS3 did introduce special selectors related to form validation. HTML CSS JavaScript #1. JavaScript and jQuery have always been a good way to implement form validation. Of course, you need to write code to do specify the validation rules. Today we will only focus on options #2 and #3 Let’s see an example: validate_07.html

Things we will want to be able to do… Explore the (new) HTML5 controls and attributes now available. Understand why these controls have been slow to be adopted. Take a second look at Regular Expressions. Discover what a CSS pseudo class is, and how some can help with form validation. Return to jQuery, and be able to identify a handler.

HTML5 controls and attributes HTML5 controls for input data GREEN = Only supported in Safari RED = Not supported in Safari How can you know? See: https://www.w3schools.com/tags/att_input_type_tel.asp Inconsistency is frustrating!….  The basic HTML5 attributes for working with forms Let’s see an example: validate_08.html Interactive examples: https://www.w3schools.com/html/html_form_input_types.asp

RegEx, again. Last class we saw jQuery’s RegEx option and the jQuery test method. Today, we see that HTML5 has RegEx support too! The new attributes to use are “title” and “pattern” See examples: validate_09.html So, if you needed to validate a telephone number, and you have a choice between validation that uses an HTML5 control of tel and a email regex pattern, which would you choose? Which would be better? Why?

CSS pseudo classes What’s a pseudo class? A CSS pseudo-class is a keyword added to a CSS selector that specifies a special state of the selected element(s). For example, :hover can be used to change a button's color when the user hovers over it. An easy example: /*apply the color when the mouse hovers over the div*/ div:hover { background-color: #39c631; } There are three pseudo classes that are most relevant to form validation: :required :valid :invalid See some examples here: validate_10.html and validate_11.html

A little bit more jQuery There are a number of jQuery methods that help us respond to events related to form validation. Here they are: focus(handler) blur(handler) change(handler) select(handler) submit(handler) We’re going to look at this one In case you haven’t noticed… we’ve been using the idea of a handler for a while now. A handler is function that executes in response to an event. A handler is always of the format: function () { /*commands go here*/ } See an example here: validate_12.html

Some thoughts… Support for the new HTML5 input controls has come a long way since they were first recommended by the W3C in 2014. However, we’ve seen today that their behavior is inconsistent across browser types. Likewise, they do not allow developers the full range of control that most solutions require. Prediction: As support for HTML5 controls continues to improve, they will eventually become mainstream. Opinion: The desired level of support is not quite there yet. Question: Even if these controls were totally, universally supported – would developers embrace them? Do end users want *every* application to be the same? Why? Why not?

Time for a challenge…