Created
September 29, 2014 09:32
-
-
Save momolog/5d2c1499b4ddd168e8bd to your computer and use it in GitHub Desktop.
How to set a custom validation message for HTML5 form inputs
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
$ -> | |
if Modernizr.input.pattern | |
$(document).bind 'change', (e) -> | |
$el = $(e.target) | |
$el[0].setCustomValidity '' | |
if $el[0] in document.querySelectorAll(':invalid') | |
if message = $el.data('invalidmessage') | |
$el[0].setCustomValidity message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment