SlideShare a Scribd company logo
Form Validation
with
HTML5
Ian Oxley
Super Mondays, 26 April 2011
$ whois

• Hi, I’m Ian
• Web / Application Developer at Sage
• http://ianoxley.com
• @ianoxley
this.talk

• HTML5 client-side <form> validation
• New <input> types and attributes make
  this really easy
• (Still need to perform validation on the
  server)
HTML4

• Client-side validation requires JavaScript
• Custom code, jQuery validate, etc.
• Extra work to give user optimal UX
• New <input> types and
  attributes
• Browsers have built-in
  client-side validation
For Example...
Required fields
<input type="text" required>
Regex with pattern
           attribute
<input type="text" required
  pattern="[A-Za-z-'0-9]+s[A-Za-z-'0-9]+"
  placeholder="Firstname Lastname">
Email Validation
<input type="email" required
placeholder="Enter your email address">
URL Validation
<input type="url" required
       placeholder="Website or blog">
Numeric Data
<input type="number" value="1"
       min="1" max="4" required>
HTML5 Forms + CSS3


• New psuedo classes for better UX
• Visual cues and feedback to guide the user
:required and :optional
:valid and :invalid,
:in-range and :out-of-range
No Validation?

<form novalidate>
  ...
</form>
Cross browser?
IE Firefox Safari Chrome Opera iPhone Android

-   4.0+   5.0+      6.0+         9.0+            -             -

                  Source: http://diveintohtml5.org/forms.html#validation
JavaScript fallback...
• Modernizr library for HTML5 detection
if (!Modernizr.input.required) {
  // Validate the old-fashioned way
  setValidationFallback();
}
Can also be used...

• In browser extensions
• Greasemonkey scripts
• Prototyping / designing in the browser
Further info
•   A Form of Madness
    http://diveintohtml5.org/forms.html

•   Forward Thinking Form Validation
    http://www.alistapart.com/articles/forward-thinking-form-
    validation/

•   New Form Features in HTML5
    http://dev.opera.com/articles/view/new-form-features-in-html5/

•   Modernizr JavaScript Library
    http://www.modernizr.com/
/(any questions)?/
Contact me

• Email: ijoxley@gmail.com
• Twitter: @ianoxley
• Demos: http://ianoxley.com/talks/
  html5forms/demos/
Ad

Recommended

Form validation client side
Form validation client side
Mudasir Syed
 
JavaScript Tutorial
JavaScript Tutorial
Bui Kiet
 
HTML5 - Forms
HTML5 - Forms
tina1357
 
Php forms
Php forms
Anne Lee
 
Javascript arrays
Javascript arrays
Hassan Dar
 
Intro to Asynchronous Javascript
Intro to Asynchronous Javascript
Garrett Welson
 
JSON: The Basics
JSON: The Basics
Jeff Fox
 
Introduction to HTML5
Introduction to HTML5
Gil Fink
 
Form using html and java script validation
Form using html and java script validation
Maitree Patel
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
PHP
PHP
Steve Fort
 
HTML
HTML
CONNECTINGTO
 
Javascript 101
Javascript 101
Shlomi Komemi
 
Javascript
Javascript
mussawir20
 
JavaScript
JavaScript
Vidyut Singhania
 
Angular 8
Angular 8
Sunil OS
 
Javascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
API for Beginners
API for Beginners
Sébastien Saunier
 
Php.ppt
Php.ppt
Nidhi mishra
 
HTML Fundamentals
HTML Fundamentals
BG Java EE Course
 
BEM It! for Brandwatch
BEM It! for Brandwatch
Max Shirshin
 
Quick flask an intro to flask
Quick flask an intro to flask
juzten
 
JavaScript: Events Handling
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Regular expression in javascript
Regular expression in javascript
Toan Nguyen
 
PHP variables
PHP variables
Siddique Ibrahim
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Introduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Html tutorial.lesson10
Html tutorial.lesson10
grassos
 
Forms with html5 (1)
Forms with html5 (1)
Anada Kale
 

More Related Content

What's hot (20)

Form using html and java script validation
Form using html and java script validation
Maitree Patel
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
PHP
PHP
Steve Fort
 
HTML
HTML
CONNECTINGTO
 
Javascript 101
Javascript 101
Shlomi Komemi
 
Javascript
Javascript
mussawir20
 
JavaScript
JavaScript
Vidyut Singhania
 
Angular 8
Angular 8
Sunil OS
 
Javascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
API for Beginners
API for Beginners
Sébastien Saunier
 
Php.ppt
Php.ppt
Nidhi mishra
 
HTML Fundamentals
HTML Fundamentals
BG Java EE Course
 
BEM It! for Brandwatch
BEM It! for Brandwatch
Max Shirshin
 
Quick flask an intro to flask
Quick flask an intro to flask
juzten
 
JavaScript: Events Handling
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Regular expression in javascript
Regular expression in javascript
Toan Nguyen
 
PHP variables
PHP variables
Siddique Ibrahim
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Introduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Form using html and java script validation
Form using html and java script validation
Maitree Patel
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Angular 8
Angular 8
Sunil OS
 
Javascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
BEM It! for Brandwatch
BEM It! for Brandwatch
Max Shirshin
 
Quick flask an intro to flask
Quick flask an intro to flask
juzten
 
Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Regular expression in javascript
Regular expression in javascript
Toan Nguyen
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Introduction to Javascript
Introduction to Javascript
Amit Tyagi
 

Viewers also liked (7)

Html tutorial.lesson10
Html tutorial.lesson10
grassos
 
Forms with html5 (1)
Forms with html5 (1)
Anada Kale
 
Design Strategy: The Rise of a New Culture
Design Strategy: The Rise of a New Culture
Payam Shalchian
 
html 5 new form attribute
html 5 new form attribute
Priyanka Rasal
 
HTML Forms Tutorial
HTML Forms Tutorial
ProdigyView
 
New Form Element in HTML5
New Form Element in HTML5
Zahra Rezwana
 
Logo Design basics
Logo Design basics
Greg Sarles
 
Html tutorial.lesson10
Html tutorial.lesson10
grassos
 
Forms with html5 (1)
Forms with html5 (1)
Anada Kale
 
Design Strategy: The Rise of a New Culture
Design Strategy: The Rise of a New Culture
Payam Shalchian
 
html 5 new form attribute
html 5 new form attribute
Priyanka Rasal
 
HTML Forms Tutorial
HTML Forms Tutorial
ProdigyView
 
New Form Element in HTML5
New Form Element in HTML5
Zahra Rezwana
 
Logo Design basics
Logo Design basics
Greg Sarles
 
Ad

Similar to HTML5 Form Validation (20)

Html5 inputs
Html5 inputs
Chris Love
 
form_validation_with_html5
form_validation_with_html5
Ryan Williams
 
HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input Validation
Todd Anglin
 
A Sensational Exposé With Bewildering Demonstrations
A Sensational Exposé With Bewildering Demonstrations
Peter Gasston
 
JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
HTML5 Forms OF DOOM
HTML5 Forms OF DOOM
Stephanie Hobson
 
Html5 Forms in Squiz Matrix - Dave Letorey
Html5 Forms in Squiz Matrix - Dave Letorey
Squiz
 
HTML5 Forms - KISS time - Fronteers
HTML5 Forms - KISS time - Fronteers
Robert Nyman
 
Forms
Forms
Aaron Maturen
 
ch3.ppt
ch3.ppt
EnghamzaKhalailah
 
Html tables, forms and audio video
Html tables, forms and audio video
Saad Sheikh
 
HTML5 workshop, forms
HTML5 workshop, forms
Robert Nyman
 
Moving to the client - HTML5 is here
Moving to the client - HTML5 is here
Christian Heilmann
 
Forms with html5
Forms with html5
Suvarna Pappu
 
Web Forms People Don't Hate
Web Forms People Don't Hate
cliener
 
Accessible dynamic forms
Accessible dynamic forms
Dylan Barrell
 
Web topic 22 validation on web forms
Web topic 22 validation on web forms
CK Yang
 
Getting Information through HTML Forms
Getting Information through HTML Forms
Mike Crabb
 
html forms 2.pptx
html forms 2.pptx
AmanRaja20
 
Form Validation in JavaScript
Form Validation in JavaScript
Ravi Bhadauria
 
form_validation_with_html5
form_validation_with_html5
Ryan Williams
 
HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input Validation
Todd Anglin
 
A Sensational Exposé With Bewildering Demonstrations
A Sensational Exposé With Bewildering Demonstrations
Peter Gasston
 
JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
Html5 Forms in Squiz Matrix - Dave Letorey
Html5 Forms in Squiz Matrix - Dave Letorey
Squiz
 
HTML5 Forms - KISS time - Fronteers
HTML5 Forms - KISS time - Fronteers
Robert Nyman
 
Html tables, forms and audio video
Html tables, forms and audio video
Saad Sheikh
 
HTML5 workshop, forms
HTML5 workshop, forms
Robert Nyman
 
Moving to the client - HTML5 is here
Moving to the client - HTML5 is here
Christian Heilmann
 
Web Forms People Don't Hate
Web Forms People Don't Hate
cliener
 
Accessible dynamic forms
Accessible dynamic forms
Dylan Barrell
 
Web topic 22 validation on web forms
Web topic 22 validation on web forms
CK Yang
 
Getting Information through HTML Forms
Getting Information through HTML Forms
Mike Crabb
 
html forms 2.pptx
html forms 2.pptx
AmanRaja20
 
Form Validation in JavaScript
Form Validation in JavaScript
Ravi Bhadauria
 
Ad

Recently uploaded (20)

Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 

HTML5 Form Validation

Editor's Notes