SlideShare a Scribd company logo
Come to the dark side. We have cookies.

FORMS OF DOOM
Attributes
Input Types
JavaScript API
Styling

BEHOLD THE POWERS OF HTML5
Placeholder
Required
Autofocus
Autocomplete
Spellcheck
Pattern

ATTRIBUTES TO RULE THEM ALL
• Disappears as the user types.
• NOT a replacement for a proper label. I will hunt you down.
• Validated by supporting browsers.
• Gives the first field in the source order with autofocus focus on page
load.
• Will scroll the page to give it focus.
• Not supported by mobile browsers.
• Suggests to browsers that they not auto fill that form field.
• Suggested for use on form fields the browser will probably auto fill
    wrong. For example: Name when you want a pet’s name.
• Also accepts “true”.
• Tells the browser explicitly whether or not to spell check the field.
• Good for fields where the input is expected to be interpreted as a
     misspelling.
• Matches a regular expression.
• Only validates if something has been entered.
• Error message is non-specific. Some browsers will use title attribute to
     explain.
• Use the title attribute to add additional help text. Please.
    • This works with all the input types.
CODING IMPRESSIVE.
Download the sample form: stephaniehobson.ca/html5forms

Add:
• Placeholder
• Required
• Autofocus
•Autocomplete (to the nemesis name field – wouldn’t want to submit your
     own name as your nemesis, that’d be awkward)
•Spellcheck (to the nemesis name field)
• Pattern
Email
URL
Tel
Search
Number
Range
Date
Datalist

INPUT TYPES AND YOUR LITTLE
DOG TOO
• For email addresses.
• Gives email keyboard.
• Is validated as an email address.
•Special attribute:
    • multiple (enables acceptance of a comma separated list of addresses)
• For urls.
• Gives url keyboard.
• Is validated as a url – very loosely.
    • URL validation is actually really complicated.
    • Use in combination with pattern if you want something specific.
• For phone numbers.
• Gives number pad.
• Very loosely validated.
    • Handy since the nice big number pad is handy for inputting any number so
         you can use it for anything else you like. thisisourstop.com uses it for
         bus stop number.
    • Use with pattern if you have
         something specific in mind.
• No standard functionality.
•Remembered search terms on some.
• Rounded corners on some.
    • Over ride with -webkit-appearance:none;
• Little grey clear field “x” on some.
• For numbers. Also called a “spinbox”.
• Gives number keypad.
• Validated as a number (one day).
•Special attributes:
    • min
    • max
    • step
• Special pseudo classes:
    • :in-range { }
    • :out-of-range { }
• For numbers. Also called a “slider”.
• Exact number not displayed to user.
• Special attributes:
    • min
    • max
    • step
• Special pseudo classes:
    • :in-range { }
    • :out-of-range { }
• On focus displays a date picker.
• Configurable formats:
    •   type=“date”
    •   type=“datetime”
    •   type=“datetime-local”
    •   type=“month”
    •   type=“week”
    •   type=“time”
• Support for everything except
    type=“date” is spotty.
• Text box with filtered list of suggestions.
• Replaces a select box with an “other
    please specify” option.
• Entire list isn’t usually visible, appears as
    user types, filtered by what they’ve
    entered.
• Backwards compatible: http://goo.gl/GhfEl
CODING MOST IMPRESSIVE.
Using the same form change:

• Birth/death date to date
• Army size to range
• Nemesis to datalist (Use Jeremy Keiths’ backwards compatible version
http://goo.gl/GhfEl)
Compatibility Tables
•http://wufoo.com/html5/ In depth and up to date.
Fallbacks
• All new inputs fall back to text automatically. Isn’t that awesome!
    • That means if you have a form with no validation today, you have have
         validation for modern browsers with small changes! So cool! You should
         run home and do this.
• Backwards compatible datalist: http://adactio.com/journal/4272/
Shims
•https://github.com/ryanseddon/H5F
• In early 2012 not all played nice with jQuery form validation plug-ins.
     Not sure if this has changed.

SUPPORT DO YOU KNOW HOW I
GOT THESE SCARS?
FormData
Constraint Validation
A Few More Elements

JAVASCRIPT API WITH FRICKIN
LASER BEAMS
• Create and send a virtual form. No need to create DOM elements.

varformData = new FormData();
formData.append(“weapon”, “Death Ray”);
formData.append(“cybernetics”, “eye, left arm”)

varxhr = new XMLHttpRequest();
xhr.open("POST", "http://goci.com/submission.php");
xhr.send(formData);
• Can also be used to append data to an existing form before sending.

varformElement = document.getElementById(”myForm");
varformData = new FormData(formElement);
formData.append(”Sidekick", "Harley Quinn,");

varxhr = new XMLHttpRequest();
xhr.open("POST", "http://goci.com/submission.php");
xhr.send(formData);
• Form elements have an object you can access with several attributes
that will tell you if and how a form field is failing validation.

el.validity.valid
el.validity.valueMissing
el.validity.typeMismatch
el.validity.patternMismatch
el.validity.tooLong
el.validity.rangeUnderflow and rangeOverflow
el.validity.stepMismatch
el.validity.customError

• Yes, custom errors! You can create your own errors using their API.
• Create a custom error message. Like, checking two email addresses match.

<input type="email" id="email_addr" name="email_addr">
<input type="email" id="email_addr_repeat" name="email_addr_repeat"
oninput="check(this)">

<script>
function check(input) {
  if (input.value != document.getElementById('email_addr').value) {
input.setCustomValidity('The two email addresses must match.');
  } else {
    // input is valid -- reset the error message
input.setCustomValidity('');
  }
}
</script>
CODING
Add the code to check the email address (I hate these but it *is* an evil
application form after all).

You can copy and paste the code from here:
http://www.html5rocks.com/en/tutorials/forms/html5forms/
:required
:optional
:valid
:invalid
:default

[attribute]

STYLING CUSTOM BABY SEAL
LEATHER BOOTS ANYONE?
Basic Introductions
•http://diveintohtml5.info/forms.html
•http://24ways.org/2009/have-a-field-day-with-html5-forms/
•http://www.html5rocks.com/en/tutorials/forms/html5forms/
•http://www.alistapart.com/articles/forward-thinking-form-validation/
CSS
•http://html5doctor.com/css3-pseudo-classes-and-html5-forms/
Compatibility Specifics
• http://wufoo.com/html5/
• http://miketaylr.com/code/input-type-attr.html

RESOURCES I SEE YOU BROUGHT A
FRIEND.

More Related Content

What's hot (8)

PPTX
#SPSLondon - Session 2 JSLink for IT Pros
Paul Hunt
 
PDF
Web Safe Fonts are Dead Series | Part 1: Web Typography Reincarnated
Extensis
 
PPT
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
BookNet Canada
 
PDF
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura Brady
BookNet Canada
 
PPTX
JavaScript : A trending scripting language
AbhayDhupar
 
PPTX
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
BookNet Canada
 
PPTX
SPSTC - SharePoint & jQuery Essentials
Mark Rackley
 
PPT
Is it time to start using HTML 5
Ravi Raj
 
#SPSLondon - Session 2 JSLink for IT Pros
Paul Hunt
 
Web Safe Fonts are Dead Series | Part 1: Web Typography Reincarnated
Extensis
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
BookNet Canada
 
Ebook Accessibility: Why, How, and What For - ebookcraft 2016 - Laura Brady
BookNet Canada
 
JavaScript : A trending scripting language
AbhayDhupar
 
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
BookNet Canada
 
SPSTC - SharePoint & jQuery Essentials
Mark Rackley
 
Is it time to start using HTML 5
Ravi Raj
 

Similar to HTML5 Forms OF DOOM (20)

PPTX
html 5 new form attribute
Priyanka Rasal
 
PPT
HTML5 Mullet: Forms & Input Validation
Todd Anglin
 
PDF
HTML5 Forms - KISS time - Fronteers
Robert Nyman
 
PPT
ch3.ppt
EnghamzaKhalailah
 
PPTX
Forms with html5
Suvarna Pappu
 
PPTX
Forms with html5 (1)
Anada Kale
 
PDF
Web Forms People Don't Hate
cliener
 
DOCX
Html5 forms input types
sinhacp
 
PPTX
html forms 2.pptx
AmanRaja20
 
PDF
Forms
Aaron Maturen
 
PPTX
Html tables, forms and audio video
Saad Sheikh
 
PPTX
HTML DAY 4 presentation for beginners friendly
RohitKrishnan32
 
PPTX
Html5 inputs
Chris Love
 
PDF
HTML5 workshop, forms
Robert Nyman
 
KEY
Building & Breaking Web Forms with Quaid-JS
cliener
 
KEY
HTML5 Form Validation
Ian Oxley
 
PPT
Web forms and html (lect 4)
Salman Memon
 
PPTX
HTML Forms: The HTML element represents a document section containing interac...
BINJAD1
 
PDF
New Perspectives on HTML and CSS Comprehensive 6th Edition Carey Test Bank
tvitoshapha
 
PDF
New Perspectives on HTML CSS and XML Comprehensive 4th Edition Carey Test Bank
vathyjenson
 
html 5 new form attribute
Priyanka Rasal
 
HTML5 Mullet: Forms & Input Validation
Todd Anglin
 
HTML5 Forms - KISS time - Fronteers
Robert Nyman
 
Forms with html5
Suvarna Pappu
 
Forms with html5 (1)
Anada Kale
 
Web Forms People Don't Hate
cliener
 
Html5 forms input types
sinhacp
 
html forms 2.pptx
AmanRaja20
 
Html tables, forms and audio video
Saad Sheikh
 
HTML DAY 4 presentation for beginners friendly
RohitKrishnan32
 
Html5 inputs
Chris Love
 
HTML5 workshop, forms
Robert Nyman
 
Building & Breaking Web Forms with Quaid-JS
cliener
 
HTML5 Form Validation
Ian Oxley
 
Web forms and html (lect 4)
Salman Memon
 
HTML Forms: The HTML element represents a document section containing interac...
BINJAD1
 
New Perspectives on HTML and CSS Comprehensive 6th Edition Carey Test Bank
tvitoshapha
 
New Perspectives on HTML CSS and XML Comprehensive 4th Edition Carey Test Bank
vathyjenson
 
Ad

More from Stephanie Hobson (9)

PDF
Writing for Every Reader - Design and Content
Stephanie Hobson
 
PDF
Flipping Tables: Displaying Data on Small Screens
Stephanie Hobson
 
PDF
Writing for Every Reader
Stephanie Hobson
 
PDF
Flipping Tables: Displaying Data on Small Screens (2016-08)
Stephanie Hobson
 
PDF
Flipping Tables: Displaying Data on Small Screens (2016-02)
Stephanie Hobson
 
PPTX
Web Accessibility: 
Making Websites Better for Everyone
Stephanie Hobson
 
PDF
Mobile First Is Performance First
Stephanie Hobson
 
PPTX
Accessibility with CSS: Making Websites Better for Everyone
Stephanie Hobson
 
PPTX
Geolocation
Stephanie Hobson
 
Writing for Every Reader - Design and Content
Stephanie Hobson
 
Flipping Tables: Displaying Data on Small Screens
Stephanie Hobson
 
Writing for Every Reader
Stephanie Hobson
 
Flipping Tables: Displaying Data on Small Screens (2016-08)
Stephanie Hobson
 
Flipping Tables: Displaying Data on Small Screens (2016-02)
Stephanie Hobson
 
Web Accessibility: 
Making Websites Better for Everyone
Stephanie Hobson
 
Mobile First Is Performance First
Stephanie Hobson
 
Accessibility with CSS: Making Websites Better for Everyone
Stephanie Hobson
 
Geolocation
Stephanie Hobson
 
Ad

Recently uploaded (20)

PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Digital Circuits, important subject in CS
contactparinay1
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 

HTML5 Forms OF DOOM

  • 1. Come to the dark side. We have cookies. FORMS OF DOOM
  • 4. • Disappears as the user types. • NOT a replacement for a proper label. I will hunt you down.
  • 5. • Validated by supporting browsers.
  • 6. • Gives the first field in the source order with autofocus focus on page load. • Will scroll the page to give it focus. • Not supported by mobile browsers.
  • 7. • Suggests to browsers that they not auto fill that form field. • Suggested for use on form fields the browser will probably auto fill wrong. For example: Name when you want a pet’s name.
  • 8. • Also accepts “true”. • Tells the browser explicitly whether or not to spell check the field. • Good for fields where the input is expected to be interpreted as a misspelling.
  • 9. • Matches a regular expression. • Only validates if something has been entered. • Error message is non-specific. Some browsers will use title attribute to explain. • Use the title attribute to add additional help text. Please. • This works with all the input types.
  • 10. CODING IMPRESSIVE. Download the sample form: stephaniehobson.ca/html5forms Add: • Placeholder • Required • Autofocus •Autocomplete (to the nemesis name field – wouldn’t want to submit your own name as your nemesis, that’d be awkward) •Spellcheck (to the nemesis name field) • Pattern
  • 12. • For email addresses. • Gives email keyboard. • Is validated as an email address. •Special attribute: • multiple (enables acceptance of a comma separated list of addresses)
  • 13. • For urls. • Gives url keyboard. • Is validated as a url – very loosely. • URL validation is actually really complicated. • Use in combination with pattern if you want something specific.
  • 14. • For phone numbers. • Gives number pad. • Very loosely validated. • Handy since the nice big number pad is handy for inputting any number so you can use it for anything else you like. thisisourstop.com uses it for bus stop number. • Use with pattern if you have something specific in mind.
  • 15. • No standard functionality. •Remembered search terms on some. • Rounded corners on some. • Over ride with -webkit-appearance:none; • Little grey clear field “x” on some.
  • 16. • For numbers. Also called a “spinbox”. • Gives number keypad. • Validated as a number (one day). •Special attributes: • min • max • step • Special pseudo classes: • :in-range { } • :out-of-range { }
  • 17. • For numbers. Also called a “slider”. • Exact number not displayed to user. • Special attributes: • min • max • step • Special pseudo classes: • :in-range { } • :out-of-range { }
  • 18. • On focus displays a date picker. • Configurable formats: • type=“date” • type=“datetime” • type=“datetime-local” • type=“month” • type=“week” • type=“time” • Support for everything except type=“date” is spotty.
  • 19. • Text box with filtered list of suggestions. • Replaces a select box with an “other please specify” option. • Entire list isn’t usually visible, appears as user types, filtered by what they’ve entered. • Backwards compatible: http://goo.gl/GhfEl
  • 20. CODING MOST IMPRESSIVE. Using the same form change: • Birth/death date to date • Army size to range • Nemesis to datalist (Use Jeremy Keiths’ backwards compatible version http://goo.gl/GhfEl)
  • 21. Compatibility Tables •http://wufoo.com/html5/ In depth and up to date. Fallbacks • All new inputs fall back to text automatically. Isn’t that awesome! • That means if you have a form with no validation today, you have have validation for modern browsers with small changes! So cool! You should run home and do this. • Backwards compatible datalist: http://adactio.com/journal/4272/ Shims •https://github.com/ryanseddon/H5F • In early 2012 not all played nice with jQuery form validation plug-ins. Not sure if this has changed. SUPPORT DO YOU KNOW HOW I GOT THESE SCARS?
  • 22. FormData Constraint Validation A Few More Elements JAVASCRIPT API WITH FRICKIN LASER BEAMS
  • 23. • Create and send a virtual form. No need to create DOM elements. varformData = new FormData(); formData.append(“weapon”, “Death Ray”); formData.append(“cybernetics”, “eye, left arm”) varxhr = new XMLHttpRequest(); xhr.open("POST", "http://goci.com/submission.php"); xhr.send(formData);
  • 24. • Can also be used to append data to an existing form before sending. varformElement = document.getElementById(”myForm"); varformData = new FormData(formElement); formData.append(”Sidekick", "Harley Quinn,"); varxhr = new XMLHttpRequest(); xhr.open("POST", "http://goci.com/submission.php"); xhr.send(formData);
  • 25. • Form elements have an object you can access with several attributes that will tell you if and how a form field is failing validation. el.validity.valid el.validity.valueMissing el.validity.typeMismatch el.validity.patternMismatch el.validity.tooLong el.validity.rangeUnderflow and rangeOverflow el.validity.stepMismatch el.validity.customError • Yes, custom errors! You can create your own errors using their API.
  • 26. • Create a custom error message. Like, checking two email addresses match. <input type="email" id="email_addr" name="email_addr"> <input type="email" id="email_addr_repeat" name="email_addr_repeat" oninput="check(this)"> <script> function check(input) { if (input.value != document.getElementById('email_addr').value) { input.setCustomValidity('The two email addresses must match.'); } else { // input is valid -- reset the error message input.setCustomValidity(''); } } </script>
  • 27. CODING Add the code to check the email address (I hate these but it *is* an evil application form after all). You can copy and paste the code from here: http://www.html5rocks.com/en/tutorials/forms/html5forms/
  • 29. Basic Introductions •http://diveintohtml5.info/forms.html •http://24ways.org/2009/have-a-field-day-with-html5-forms/ •http://www.html5rocks.com/en/tutorials/forms/html5forms/ •http://www.alistapart.com/articles/forward-thinking-form-validation/ CSS •http://html5doctor.com/css3-pseudo-classes-and-html5-forms/ Compatibility Specifics • http://wufoo.com/html5/ • http://miketaylr.com/code/input-type-attr.html RESOURCES I SEE YOU BROUGHT A FRIEND.

Editor's Notes

  • #3: Mobile vs DesktopSome can be used today
  • #4: These apply to almost all input types, existing and new
  • #11: You are WEB MASTER for the Guild of Calamitous Intent
  • #15: Use pattern if you want it in a certain format
  • #16: Apple’s baby so Safari handles it best.Some remember last few searches.Some give little grey X.Can be combined with datalist to provide search suggestions
  • #19: Support for this one is really spotty
  • #21: You are WEB MASTER for the Guild of Calamitous Intent
  • #22: Fallbacks – to text! Isn’t that awesome!ShimsThese do not place nice with many existing jQuery plug ins :(
  • #24: Create a form altogether. Virtually in JavaSript. No need to create hidden forms in the DOM.
  • #25: Append to an existing form
  • #26: New attribute called validityReturns the validityState object which has several boolean attributes (basically a series of true/false tests)
  • #28: You are WEB MASTER for the Guild of Calamitous Intent
  • #29: Some of the problems with timing.