YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Html5 Forms in Squiz Matrix - Dave Letorey

HTML 5 Forms in Matrix!Dave Letorey – Squiz UK!@dletorey!

Page 2: Html5 Forms in Squiz Matrix - Dave Letorey

HTML5 Form Input Types!

•  There are a number of new input types in the HTML 5 spec!•  Date!•  Time!•  Month!•  Week!•  Datetime-local!•  Email!

•  Number!•  Range!•  Tel!•  URL!•  Color!•  Search!

Page 3: Html5 Forms in Squiz Matrix - Dave Letorey

HTML5 Input Types!

•  All of these new input types, if not supported by the users browser, will fallback to Text input fields!

Page 4: Html5 Forms in Squiz Matrix - Dave Letorey

Creating an HTML 5 form in Matrix!•  As these new input types are not in

Matrix, these all need to be added as Text field type!•  This is good as the fallback type is a

text type!

Page 5: Html5 Forms in Squiz Matrix - Dave Letorey

Changing the Default Output!

•  This is Achieved using Page Contents & Thank You bodycopies!

Page 6: Html5 Forms in Squiz Matrix - Dave Letorey

Page Contents code!<input name="qxxx:qy" id="xxx:qy"type="zzz" />!

Where: !•  xxx is the assetid for the form/section!•  y is the question number!•  zzz is the input type e.g. email, text, tel,

date, time, etc.!

Page 7: Html5 Forms in Squiz Matrix - Dave Letorey

Thank you code!

zzz: %response_xxx_qy%!Where: !•  xxx is the assetid for the form/

section!•  y is the question number!•  zzz is the name of your question.!

Page 8: Html5 Forms in Squiz Matrix - Dave Letorey

Required attribute!

•  HTML5 form inputs have a required attribute!•  The browser will then add a message

if it is not filled in!

Page 9: Html5 Forms in Squiz Matrix - Dave Letorey

Required syntax!

<input type="text" required />!or!

<input type="text" required="required" />!

!HTML5 does not require the quotes!

Page 10: Html5 Forms in Squiz Matrix - Dave Letorey

Autofocus attribute!

This attribute will give focus to an input field when the page is loaded!Syntax:!

<input type="text" autofocus />!

!

Page 11: Html5 Forms in Squiz Matrix - Dave Letorey

Placeholder attribute!

The placeholder attribute is used to populate text that gives the user a hint as to what to do. !The text is removed when the field has focus!

Page 12: Html5 Forms in Squiz Matrix - Dave Letorey

Placeholder syntax!

<input type="text" placeholder="http://www.example.com" />!

!

Page 13: Html5 Forms in Squiz Matrix - Dave Letorey

Pattern attribute!

The input types: email, number, url, etc are really baked-in regular expression!Using the pattern attribute you can add regular expressions to any input type!Syntax:!

<input type="text" pattern="[reg-exp]" />!

Page 14: Html5 Forms in Squiz Matrix - Dave Letorey

Min Max attribute!!

A Min & Max can be set on Date, Time, Number, Range, etc input types!Syntax:!

<input type="date" min="1969-08-26"

max="2012-07-4" />!!

Page 15: Html5 Forms in Squiz Matrix - Dave Letorey

Step attribute!

For input types that involve numbers, e.g. you can make them step in increments!Syntax:!<input type="range" min="0"

max="100" step="5" />!!

Page 16: Html5 Forms in Squiz Matrix - Dave Letorey

Styling Input fields with CSS!

CSS3 introduced 2 new pseudo classes for form inputs!input:valid {!!background-color: green;!}!input:invalid {!!background-color: red;!}!!

Page 17: Html5 Forms in Squiz Matrix - Dave Letorey

Why should I care about this?!

•  It makes it easier for users to fill in your forms!•  It makes forms much more accessible!

Page 18: Html5 Forms in Squiz Matrix - Dave Letorey

Input Support!

supported !partial!not supported!

Page 19: Html5 Forms in Squiz Matrix - Dave Letorey

Attribute Support!

supported !partial!not supported!http://wufoo.com/html5 !

Page 20: Html5 Forms in Squiz Matrix - Dave Letorey

type="date"!

Page 21: Html5 Forms in Squiz Matrix - Dave Letorey

type="time"!

Page 22: Html5 Forms in Squiz Matrix - Dave Letorey

type="range"!

Page 23: Html5 Forms in Squiz Matrix - Dave Letorey

type="email"!

Page 24: Html5 Forms in Squiz Matrix - Dave Letorey

Modernizr + Polyfills!

•  Modernizr is a JavaScript file that detects if a browser supports the new features!•  http://modernizr.com/!

•  Polyfills can be used to add these new input fields and attributes into browser that do not support them!

Page 25: Html5 Forms in Squiz Matrix - Dave Letorey

Modernizr + Polyfills!

•  Polyfills:!•  webforms2 https://github.com/westonruter/webforms2!

•  html5formshttps://github.com/zoltan-dulac/html5Forms.js!

Page 26: Html5 Forms in Squiz Matrix - Dave Letorey

Resources!HTML5 forms!•  Form Input types:http://bit.ly/sfusers01!

•  HTML 5 rocks:http://bit.ly/sfusers02!

•  Dive into HTML 5:http://bit.ly/sfusers03!

•  Introducing HTML5:http://bit.ly/sfusers04!

Page 27: Html5 Forms in Squiz Matrix - Dave Letorey

Resources!

Support!•  Can I Use:http://bit.ly/sfusers05!

•  Current Support:http://bit.ly/sfusers06!

Page 28: Html5 Forms in Squiz Matrix - Dave Letorey

Resources!Polyfills!•  Progressively enhancing HTML5 forms:http://bit.ly/sfusers07!

•  Making HTML5 & CSS3 work with Polyfills & Shims:http://bit.ly/sfusers08!

•  Using modernizr & html5forms:http://bit.ly/sfusers09!

•  Modernizr:http://bit.ly/sfusers10!

•  html5forms.js:http://bit.ly/sfusers11!

•  webforms2:http://bit.ly/sfusers12!

Page 29: Html5 Forms in Squiz Matrix - Dave Letorey

Resources!

Example!•  Example you can play with:http://bit.ly/sfusers13!


Related Documents