HTML5 workshop, forms
Upcoming SlideShare
Loading in...5
×
 

HTML5 workshop, forms

on

  • 1,964 views

Workshop given at Jfokus 2012

Workshop given at Jfokus 2012

Statistics

Views

Total Views
1,964
Views on SlideShare
1,962
Embed Views
2

Actions

Likes
5
Downloads
110
Comments
0

2 Embeds 2

https://twimg0-a.akamaihd.net 1
http://pmomale-ld1 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

HTML5 workshop, forms HTML5 workshop, forms Presentation Transcript

  • HTML5 Forms - KISS time
  • Forms
  • Thou shalt make things simple
  • Types
  • New form types<input type="color"> <input type="range"><input type="date"> <input type="search" results="5"<input type="datetime"> autosave="saved-searches"><input type="datetime-local"> <input type="tel"><input type="email"> <input type="time"><input type="month"> <input type="url"><input type="number"> <input type="week">
  • Attributes
  • New form attributes<input type="text" autocomplete="off"><input type="text" autofocus><input type="submit" formaction="http://example.org/save" value="Save"><input type="submit" formenctype="application/x-www-form-urlencoded" value="Save with enctype"><input type="submit" formmethod="POST" value="Send as POST"><input type="submit" formnovalidate value="Dont validate"><input type="submit" formtarget="_blank" value="Post to new tab/window">
  • <input type="text" list="data-list"><input type="range" max="95"><input type="range" min="2"><input type="file" multiple><input type="text" readonly><input type="text" required><input type="text" pattern="[A-Z]*"><input type="text" placeholder="E.g. Robocop"><input type="text" spellcheck="true"><input type="number" step="5">
  • <input type="text" mozactionhint="Next">
  • Elements
  • New form elements<input type="text" list="data-list"><datalist id="data-list"> <option value="Hugo Reyes"> <option value="Jack Shephard"> <option value="James Sawyer Ford"> <option value="John Locke"> <option value="Sayid Jarrah"></datalist>
  • <keygen></keygen><meter min="0" max="10" value="7"></meter><input type="range" id="range"><output for="range" id="output"></output><progress max="100" value="70">70%</progress>
  • <input type="range" id="da-range"><output id="da-range-output"></output><script> (function () { var range = document.getElementById("da-range"), output = document.getElementById("da-range-output"); range.addEventListener("input", function () { output.value = this.value; }, false); })();</script>
  • Validation
  • <input type="text" required>
  • Only spaces are regarded as input :-(
  • <input type="text" requiredstyle="visibility: hidden">
  • No dialog, wont submit formDialog at elementNo dialog, wont submit formDialog at top left of screen (notbrowser)
  • <input type="email" required>
  • No support for internationalcharacters, i.e.röja@kissonline.com wont work
  • <input type="text" pattern="d{2}-d{5}">
  • Empty fields are seen as valid
  • <input type="text" title="So you triedto skip me?" required>
  • <input type="text" pattern="d{2}-d{5}"x-moz-errormessage="PLEASE, just do itright!">
  • elm.setCustomValidity("No, thats wrong!");
  • Remove custom validation messageby setting it to an empty string...
  • elm.setCustomValidity("");
  • Using setCustomValidity totallykills the checkValidity method
  • (function () { var oninvalidTest = document.getElementById("oninvalid-test"); oninvalidTest.addEventListener("input", function () { this.setCustomValidity(""); }, false); oninvalidTest.addEventListener("invalid", function () { this.setCustomValidity("No, thats wrong!"); }, false);})();
  • Styling
  • input:required { border: 1px solid #00f;}
  • input:valid { border: 1px solid #0f0;}input:invalid { border: 1px solid #f00;}input:out-of-range { border: 1px solid #f00;}
  • input:focus:invalid { border: 1px solid #f00;}
  • input:-moz-ui-valid { border: 1px solid #0f0;}input:-moz-ui-invalid { border: 1px solid #f00;}
  • input:-moz-placeholder { color: #f00; background: yellow;}input::-webkit-input-placeholder { color: #f00; background: yellow;}
  • Works in Safari, but only with thetext color, not the background
  • input::-webkit-validation-bubble-message { color: #f00; background: #000; border: 10px solid #f00; -webkit-box-shadow: 0 0 0 0;}input::-webkit-validation-bubble-arrow { background: #ff3456; border-color: orange; -webkit-box-shadow: 0 0 0 0;}
  • http://www.quirksmode.org/ html5/inputs.html http://www.quirksmode.org/ html5/inputs_mobile.htmlhttp://wufoo.com/html5/
  • Robert Nymanrobertnyman.com/speaking/ robnyman@mozilla.comrobertnyman.com/html5/ Twitter: @robertnymanrobertnyman.com/css3/