Top Banner
Web Forms People Don’t Hate Chris Lienert @cliener
104

Web Forms People Don't Hate

Dec 17, 2014

Download

Technology

cliener

Presentation from the Edge of the Web conference on March 15 2013 in Perth, Australia
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web Forms People Don't Hate

Web FormsPeople

Don’t Hate

Chris Lienert@cliener

Page 2: Web Forms People Don't Hate

Ooh!Double Negative!

Page 3: Web Forms People Don't Hate

Love

Page 4: Web Forms People Don't Hate

Ooh!Double Negative!EotW

Page 5: Web Forms People Don't Hate

End of the World

Page 6: Web Forms People Don't Hate

I work for Jardine Lloyd Thompson

Page 7: Web Forms People Don't Hate

Who used to smuggle opium

Page 8: Web Forms People Don't Hate

Insurance means forms

Page 9: Web Forms People Don't Hate

And forms

Page 10: Web Forms People Don't Hate

And more forms

Page 11: Web Forms People Don't Hate

Imagine filling that out online

Page 12: Web Forms People Don't Hate

Or on your mobile

Page 13: Web Forms People Don't Hate

Design Patterns

http://www.lukew.com/resources/web_form_design.asp

Page 14: Web Forms People Don't Hate

Design Patterns

Vertical label/field

Page 15: Web Forms People Don't Hate

Vertical Label/Field

Page 16: Web Forms People Don't Hate

Design Patterns

Vertical label/fieldHorizontal (search)

Page 17: Web Forms People Don't Hate

Horizontal (Search)

Page 18: Web Forms People Don't Hate

Design Patterns

Vertical label/fieldHorizontal (search)Clear path to completion

Page 19: Web Forms People Don't Hate

Clear Path to Completion

Page 20: Web Forms People Don't Hate

Design Patterns

Vertical label/fieldHorizontal (search)Clear path to completionMark optional fields

Page 21: Web Forms People Don't Hate

Mark Optional Fields

Page 22: Web Forms People Don't Hate

Don’t do this

Page 23: Web Forms People Don't Hate

Build

Form

Page 24: Web Forms People Don't Hate

Build

FormFieldset

Page 25: Web Forms People Don't Hate

Build

FormFieldset[no caption]

Page 26: Web Forms People Don't Hate

Build

FormFieldset[no caption]Block element (p, li, th, td)

Page 27: Web Forms People Don't Hate

Build

FormFieldset[no caption]Block element (p, li, th, td)Label (id)

Page 28: Web Forms People Don't Hate

Build

FormFieldset[no caption]Block element (p, li, th, td)Label (id)Field

Page 29: Web Forms People Don't Hate

Build

<form  method="post"  action="wds.aspx"><fieldset><p><label  for="name">Name</label>  <input  type="text"  name="name"  id="name"></p></fieldset></form>

Page 31: Web Forms People Don't Hate

HTML5 Attributes

maxlength for TextArea

Page 32: Web Forms People Don't Hate

HTML5 Attributes

maxlength for TextArearequired

Page 33: Web Forms People Don't Hate

HTML5 Attributes

maxlength for TextArearequiredplaceholder

Page 34: Web Forms People Don't Hate

HTML5 Attributes

maxlength for TextArearequiredplaceholderautocorrect="off "

Page 35: Web Forms People Don't Hate

HTML5 Attributes

maxlength for TextArearequiredplaceholderautocorrect="off "autocapitalize="off "

Page 36: Web Forms People Don't Hate

HTML5 Attributes

maxlength for TextArearequiredplaceholderautocorrect="off " autocapitalize="off "autofocus

Page 37: Web Forms People Don't Hate

Autofocus in Practice – Type…

Page 38: Web Forms People Don't Hate

Autofocus in Practice – Type…

Page 39: Web Forms People Don't Hate

Autofocus in Practice – Argh!

Page 40: Web Forms People Don't Hate

Autofocus in Practice – Argh!

FIXED!

Page 41: Web Forms People Don't Hate

HTML5 Attributes

Pattern • default error messages are awful • doesn't scale well • does a fine robot dance

Page 42: Web Forms People Don't Hate

HTML5 Attributes

Pattern • pattern="/d*"

Page 43: Web Forms People Don't Hate

HTML5 Input Types

Email • instant win • iOS keyboard love

Page 44: Web Forms People Don't Hate

HTML5 Input Types

Date, Month, Week, Time • don’t

Page 45: Web Forms People Don't Hate

HTML5 Input Types

Page 46: Web Forms People Don't Hate

HTML5 Input Types

Tel • fairly useless • iOS keyboard love

Page 47: Web Forms People Don't Hate

People get things wrong

Page 48: Web Forms People Don't Hate

Validation to the rescue!

Page 49: Web Forms People Don't Hate

You Wouldn’t Like Me When I’m Angry

Page 50: Web Forms People Don't Hate
Page 51: Web Forms People Don't Hate

Validate Early, Validate Often

Allow people to make mistakes

Page 52: Web Forms People Don't Hate

Allow People to Make Mistakes

Page 53: Web Forms People Don't Hate

Allow People to Make Mistakes

Page 54: Web Forms People Don't Hate

“The real danger is not that computers will begin to think like men, but that men will begin to

think like computers.”Sydney J Harris

Allow People to Make Mistakes

Page 55: Web Forms People Don't Hate

Allow People to Make Mistakes

Page 56: Web Forms People Don't Hate

Validate Early, Validate Often

Allow people to make mistakesClearly mark invalid fields

Page 57: Web Forms People Don't Hate

Clearly Mark Invalid Fields

Page 58: Web Forms People Don't Hate

Clearly Mark Invalid Fields

<p><label  for="birth-­‐date">Birth  Date</label>  <input  type="text"  class="date"  name="birth-­‐date"  id="birth-­‐date"  required></p>

Page 59: Web Forms People Don't Hate

Clearly Mark Invalid Fields

<p><label  for="birth-­‐date">Birth  Date</label>  <input  type="text"  class="date"  name="birth-­‐date"  id="birth-­‐date"  required  aria-­‐invalid="true">  <label  for="birth_date"  class="errata"  role="alert">Please  enter  a  value</label></p>

Page 60: Web Forms People Don't Hate

Validate Early, Validate Often

Allow people to make mistakesClearly mark invalid fieldsPattern validate on entry

Page 61: Web Forms People Don't Hate

Pattern Validate on Entry

Page 62: Web Forms People Don't Hate

Validate Early, Validate Often

Allow people to make mistakesClearly mark invalid fieldsPattern validate on entryEnforce minimum not maximum

Page 63: Web Forms People Don't Hate

Enforce Minimum not Maximum

Page 64: Web Forms People Don't Hate

Enforce Minimum not Maximum

Page 65: Web Forms People Don't Hate

http://bit.ly/Oaqlre

Distraction

Page 66: Web Forms People Don't Hate

Validate Early, Validate Often

Allow people to make mistakesClearly mark invalid fieldsPattern validate on entryEnforce minimum not maximumGet it right

Page 67: Web Forms People Don't Hate

Get it Right

Page 68: Web Forms People Don't Hate

A Bunch of Malarkey

Page 69: Web Forms People Don't Hate

Special Exhibit

Page 70: Web Forms People Don't Hate

Special Exhibit

Page 71: Web Forms People Don't Hate

Special Exhibit

Page 72: Web Forms People Don't Hate
Page 73: Web Forms People Don't Hate
Page 74: Web Forms People Don't Hate

Build

Page 75: Web Forms People Don't Hate

Build

Page 76: Web Forms People Don't Hate

Build

Page 77: Web Forms People Don't Hate

Build

Lots of coding

Page 78: Web Forms People Don't Hate

Build

Page 79: Web Forms People Don't Hate

Quaid JS

Embrace & extend HTML, DOM

Page 80: Web Forms People Don't Hate

Quaid JS

Embrace & extend HTML, DOMPolyfill older browsers

Page 81: Web Forms People Don't Hate

Embrace and Extend

Tel • phone

• mobile<input  type="tel"  class="mobile">

<input  type="tel"  class="phone">

Page 82: Web Forms People Don't Hate

Embrace and Extend

Postcode • data-­‐state-­‐field<input  type="text"  class="postcode"  data-­‐state-­‐field="state">

<select  id="state"  name="state">…</  select>

Page 83: Web Forms People Don't Hate

Embrace and Extend

Time

Date

Year

<input  type="text"  class="time">

<input  type="text"  class="date">

<input  type="text"  class="year">

Page 84: Web Forms People Don't Hate

Embrace and Extend

Numeric

Integer

Currency

<input  type="text"  class="numeric">

<input  type="text"  class="integer">

<input  type="text"  class="currency">

Page 85: Web Forms People Don't Hate

Embrace and Extend

Positive Numeric

Positive Integer

Positive Currency

<input  type="text"  class="positive_numeric">

<input  type="text"  class="positive_integer">

<input  type="text"  class="positive_currency">

Page 86: Web Forms People Don't Hate

Embrace and Extend

Credit Card

CSC

<input  type="text"  class="credit_card">

<input  type="text"  class="csc">

Page 87: Web Forms People Don't Hate

Data Attributes

Required if<input  type="checkbox"  name="variable-­‐field"  id="variable-­‐field">…<input  type="text"  name="target-­‐field"  id="target-­‐field"  data-­‐required-­‐field="variable-­‐field">

Page 88: Web Forms People Don't Hate

Data Attributes

Visible if<input  type="checkbox"  name="variable-­‐field"  id="variable-­‐field">…<p  data-­‐visible-­‐field="variable-­‐field">…</p>

Page 89: Web Forms People Don't Hate

Custom Validation

Inline$("#field").addValidation(function  (el)  {    if  (!(el.isValid  =  !el.checked))  {        el.errorMessage  =  "Check  the  box  or  else.";    }});

Page 90: Web Forms People Don't Hate

Custom Validation

On Submit$("#field").addSubmitValidation(function  (el)  {    if  (!(el.isValid  =  !el.checked))  {        el.errorMessage  =  "Check  the  box  or  else.  Really.";    }});

Page 91: Web Forms People Don't Hate

Custom Validation

Ajax Server Call$("#postcode").addServerValidation({    path:  "validation.svc/IsValidPostcode?postcode="})

Page 92: Web Forms People Don't Hate

Custom Validation

Ajax Servicepublic  ValidationResponse  IsValidPostcode(string  postcode,  string  caller){        using  (var  p  =  new  PostalAddressClient())        {                if  (!string.IsNullOrEmpty(postcode)  &&  !p.IsValidPostcode(postcode))                {                      …}

Page 93: Web Forms People Don't Hate

Custom Validation

Ajax Servicepublic  ValidationResponse  IsValidPostcode(…){                …                        return  new  ValidationResponse(…,  caller);                }        }        return  new  ValidationResponse(string.Empty,  caller);}

Page 94: Web Forms People Don't Hate

Custom Validation

Ajax Response>  validationResponse  {    message:  "",    caller:  "postcode"}

Page 95: Web Forms People Don't Hate

Plug-in Internationalisation

Custom methods and errorsquaid.forms-au-4.0.jsmessage:  {  required:      "Value  not  entered"  }

quaid.forms-ca-4.0.jsmessage:  {  required:    "Value  not  entered,  eh.  Go  Leafs!"  }

Page 96: Web Forms People Don't Hate

Elephant in the Room

Page 97: Web Forms People Don't Hate

Elephant in the Room

6+

Page 98: Web Forms People Don't Hate

6+ 3.6+

And the Rest

Page 99: Web Forms People Don't Hate

When the Lights Go Down

JavaScriptHTML5Server<label  class="server-­‐error">

Page 100: Web Forms People Don't Hate

Ready for the Taking

https://github.com/cliener/Quaid-JS

Page 103: Web Forms People Don't Hate

Standing on the Shoulders of Giants

WufooThe Current State of HTML5 Formshttp://wufoo.com/html5/

Luke WWeb Form Design: Filling in the Blankshttp://www.lukew.com/resources/web_form_design.aspEvolving E-commerce Checkouthttp://www.lukew.com/ff/entry.asp?1579

Page 104: Web Forms People Don't Hate

Standing on the Shoulders of Giants

Steve KrugDon't Make Me Thinkhttp://www.sensible.com/dmmt.html

PunkchipWAI-ARIA to enhance form validationhttp://www.punkchip.com/2010/12/aria-enhance-form-validation/