Created
September 16, 2015 23:18
-
-
Save tyrauber/5de42bf4f66c4084b99e to your computer and use it in GitHub Desktop.
HTML5 Safari Form Validation Polyfill
This file contains 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
validate_form = -> | |
$('form').submit (event) -> | |
$.each $(this).find('input'), (i,el) -> | |
validate_field(el); | |
$(el).on 'blur', -> validate_field(el) ; | |
window.validate_form = validate_form | |
validate_field = (el) -> | |
if ($(el)[0].checkValidity()) | |
$(el).removeClass('validation-error'); | |
else | |
$(el).addClass('validation-error'); | |
validate_form(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment