+ All Categories
Home > Technology > A Sensational Exposé With Bewildering Demonstrations

A Sensational Exposé With Bewildering Demonstrations

Date post: 12-May-2015
Category:
Upload: peter-gasston
View: 1,295 times
Download: 0 times
Share this document with a friend
Description:
What is the Validation API, and how does it relate to Houdini?
Popular Tags:
56
A Sensational ExposÉ With Bewildering Demonstrations By Peter Gasston Broken-links.com @stopsatgreen
Transcript
Page 1: A Sensational Exposé With Bewildering Demonstrations

A SensationalExposÉ WithBewildering

Demonstrations

By Peter GasstonBroken-links.com

@stopsatgreen

Page 2: A Sensational Exposé With Bewildering Demonstrations
Page 3: A Sensational Exposé With Bewildering Demonstrations

HARRY HOUDINI

Page 4: A Sensational Exposé With Bewildering Demonstrations
Page 5: A Sensational Exposé With Bewildering Demonstrations
Page 6: A Sensational Exposé With Bewildering Demonstrations
Page 7: A Sensational Exposé With Bewildering Demonstrations
Page 8: A Sensational Exposé With Bewildering Demonstrations

CONSTRAINT validation

Page 9: A Sensational Exposé With Bewildering Demonstrations

CONSTRAIN:

1. Severely restrictscope, extent,or activity

2. confine forcibly,as by bonds.

Page 10: A Sensational Exposé With Bewildering Demonstrations
Page 11: A Sensational Exposé With Bewildering Demonstrations

NEW INPUT TYPES

<input type=<input type=""emailemail"">><input type=<input type=""urlurl"">><input type=<input type=""teltel"">><input type=<input type=""searchsearch"">>

Page 12: A Sensational Exposé With Bewildering Demonstrations
Page 13: A Sensational Exposé With Bewildering Demonstrations

NEW INPUT TYPES

<input type=<input type=""numbernumber"">><input type=<input type=""rangerange"">>

Page 14: A Sensational Exposé With Bewildering Demonstrations
Page 15: A Sensational Exposé With Bewildering Demonstrations

NEW JS Methods

stepUp()/stepDown()stepUp()/stepDown()

valueAsNumbervalueAsNumber

NEW JS FUNCTION

Page 16: A Sensational Exposé With Bewildering Demonstrations

NEW INPUT TYPES

<input type=<input type=""datetimedatetime"">><input type=<input type=""datedate"">><input type=<input type=""monthmonth"">><input type=<input type=""weekweek"">><input type=<input type=""timetime"">>

Page 17: A Sensational Exposé With Bewildering Demonstrations
Page 18: A Sensational Exposé With Bewildering Demonstrations

NEW JS FUNCTION

valueAsDatevalueAsDate

Page 19: A Sensational Exposé With Bewildering Demonstrations

wufoo.com/html5/

Page 20: A Sensational Exposé With Bewildering Demonstrations

ADDING THECONSTRAINTs

Page 21: A Sensational Exposé With Bewildering Demonstrations

REQUIRED ATTRIBUTE

<<input type=input type=""texttext"" requiredrequired>><<input type="text"input type="text" requiredrequired=="""">><<textareatextarea requiredrequired=="""" /> />

Page 22: A Sensational Exposé With Bewildering Demonstrations

REQUIRED ATTRIBUTE

Page 23: A Sensational Exposé With Bewildering Demonstrations

SET THEERROR MESSAGE

<<input type=input type=""texttext" " x-moz-errormessagex-moz-errormessage="FooBar">="FooBar">

Page 24: A Sensational Exposé With Bewildering Demonstrations

SET THEERROR MESSAGE

Page 25: A Sensational Exposé With Bewildering Demonstrations

Pattern matching

<input type=<input type=""emailemail"">><input type=<input type="date""date">><input type=<input type=""urlurl"" required> required>

Page 26: A Sensational Exposé With Bewildering Demonstrations

Pattern matching

Page 27: A Sensational Exposé With Bewildering Demonstrations

Pattern ATTRIBUTE

<<input type=input type=""texttext"" pattern="[-0-9]+"pattern="[-0-9]+">>

Page 28: A Sensational Exposé With Bewildering Demonstrations

CONTEXTUALERROR MESSAGES

<<input type=input type=""texttext"" pattern="[-0-9]+"pattern="[-0-9]+" title="Must be a title="Must be a number"number">>

Page 29: A Sensational Exposé With Bewildering Demonstrations
Page 30: A Sensational Exposé With Bewildering Demonstrations

LIMITMAtching

<<input type=input type="number""number" max="2"max="2">><<input type=input type="range""range" min="0" min="0" max="1" step="0.1"max="1" step="0.1">><<input type=input type="text""text" maxlength="20"maxlength="20">>

Page 31: A Sensational Exposé With Bewildering Demonstrations
Page 32: A Sensational Exposé With Bewildering Demonstrations
Page 33: A Sensational Exposé With Bewildering Demonstrations
Page 34: A Sensational Exposé With Bewildering Demonstrations

BONUS SLIDE!

CSS3 UI pseudo-classes for CSS3 UI pseudo-classes for styling form states:styling form states::required:required:optional:optional:valid:valid:invalid:invalid:default:default:in-range:in-range:out-of-range:out-of-range

Page 35: A Sensational Exposé With Bewildering Demonstrations

CONSTRAINTVALIDATION

A.P.I.

Page 36: A Sensational Exposé With Bewildering Demonstrations

Is the api present?

var hasValidation =var hasValidation =(myForm.(myForm.checkValiditycheckValidity) ) ? true : false;? true : false;

Page 37: A Sensational Exposé With Bewildering Demonstrations
Page 38: A Sensational Exposé With Bewildering Demonstrations

Do not validate

<<formform novalidate>novalidate><<buttonbutton formnovalidate> formnovalidate>

Page 39: A Sensational Exposé With Bewildering Demonstrations

Do not validate

if(hasValidation === true) {if(hasValidation === true) {myForm.myForm.

setAttribute('setAttribute('novalidatenovalidate','');','');}}

Page 40: A Sensational Exposé With Bewildering Demonstrations

Feature detection

function formSubmit(evt) {function formSubmit(evt) {(hasValidation === true) ? (hasValidation === true) ? newValidation() :newValidation() :oldValidation();oldValidation();evt.preventDefault();evt.preventDefault();

}}

Page 41: A Sensational Exposé With Bewildering Demonstrations

BONUS SLIDe!

HTML5 Form Events:HTML5 Form Events:oncontextmenuoncontextmenuonformchangeonformchangeonforminputonforminputoninputoninputoninvalidoninvalid

Page 42: A Sensational Exposé With Bewildering Demonstrations

DOES THE FORM VALIDATE?

myForm.myForm.checkValidity();checkValidity();

Page 43: A Sensational Exposé With Bewildering Demonstrations

document.getElementByIddocument.getElementById('x').('x').willValidate;willValidate;

Which ELEMENTs will VALIDATE?

Page 44: A Sensational Exposé With Bewildering Demonstrations

Which ELEMENTs will VALIDATE?

var formNodes = var formNodes = myForm.childNodes.length;myForm.childNodes.length;for(i=0; i<formNodes; i++) for(i=0; i<formNodes; i++) {{if(myForm.childNodes[i]if(myForm.childNodes[i]..

willValidatewillValidate) {) {doSomethingdoSomething;;

}}}}

Page 45: A Sensational Exposé With Bewildering Demonstrations

DOES A field VALIDATE?

thisNode.thisNode.checkValidity();checkValidity();

Page 46: A Sensational Exposé With Bewildering Demonstrations

Validationstatus

thisNodethisNode..validity;validity;

Page 47: A Sensational Exposé With Bewildering Demonstrations

Validity object

customErrorcustomErrorpatternMismatchpatternMismatchrangeOverflowrangeOverflowrangeUnderflowrangeUnderflowstepMismatchstepMismatchtooLongtooLongtypeMismatchtypeMismatchvalidvalidvalueMissingvalueMissing

Page 48: A Sensational Exposé With Bewildering Demonstrations

Validity object

for(var v in thisNode.validity) {for(var v in thisNode.validity) {if (thisNode.if (thisNode.validityvalidity[v] === true) {[v] === true) {var errorMessage;var errorMessage;switch(v){switch(v){case 'valueMissing' :case 'valueMissing' :errorMessage = 'FooBar';errorMessage = 'FooBar';break;break;

}}}}

Page 49: A Sensational Exposé With Bewildering Demonstrations

SET THEERROR MESSAGE

thisNode.thisNode.setCustomValiditysetCustomValidity(errorMessage);(errorMessage);

Page 50: A Sensational Exposé With Bewildering Demonstrations

GET THEERROR MESSAGE

document.document.getElementById('x').getElementById('x').validationMessage;validationMessage;

Page 51: A Sensational Exposé With Bewildering Demonstrations

alert('The error message is: ' alert('The error message is: ' + thisNode.+ thisNode.validationMessagevalidationMessage););

Page 52: A Sensational Exposé With Bewildering Demonstrations

BONUS SLIDE!

Javascript library Javascript library to polyfill HTML5 to polyfill HTML5 form support:form support:http://thecssninja.chttp://thecssninja.com/javascript/H5Fom/javascript/H5F

Page 53: A Sensational Exposé With Bewildering Demonstrations

ESCAPING THECONSTRAINTs

Page 54: A Sensational Exposé With Bewildering Demonstrations

THE END

Page 55: A Sensational Exposé With Bewildering Demonstrations

BONUS SLIDE!

Resources:Resources:http://www.broken-http://www.broken-links.com/2011/03/28/htmllinks.com/2011/03/28/html5-form-validation/5-form-validation/

https://developer.mozillahttps://developer.mozilla.org/en/HTML/HTML5/Forms_.org/en/HTML/HTML5/Forms_in_HTML5in_HTML5

Page 56: A Sensational Exposé With Bewildering Demonstrations

THANK You.

By Peter GasstonBroken-links.com

@stopsatgreen


Recommended