Last active
January 4, 2016 05:59
-
-
Save westonwatson/8578491 to your computer and use it in GitHub Desktop.
Basic HTML5 Input (placeholder and required) Polyfill/Shim Loader using Modernizr.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//defer until Modernizr is loaded. | |
$(function () { | |
/* HTML5 Input Placeholder Polyfill. */ | |
Modernizr.load({ | |
test: Modernizr.input.placeholder, | |
nope: [ | |
'/assets/css/placeholder_polyfill.min.css', | |
'/assets/js/placeholder_polyfill.jquery.min.combo.js' | |
] | |
}); | |
/* Basic HTML5 Input Validation Polyfill. | |
* right now, we're only testing for required. if more | |
* HTML5 goodness is used, additional yepnope testers | |
* may be required. the library below covers multiple | |
* features, Check out http://ericleads.com/h5validate/ | |
*/ | |
Modernizr.load({ | |
test: Modernizr.input.required, | |
nope: [ | |
'/assets/js/jquery.h5validate.js' | |
] | |
}); | |
}); | |
//initialize h5Validation polyfill | |
$(document).ready(function () { | |
//make sure h5Validate is loaded properly | |
if (typeof jQuery.h5Validate != 'undefined') $('form').h5Validate({ | |
//custom error CSS class to use for "required" inputs | |
errorClass: "required_field" | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment