Created
March 14, 2016 12:15
-
-
Save afelicioni/d02341aae2b0cf0dc573 to your computer and use it in GitHub Desktop.
custom validation email input message
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
[].forEach.call( document.querySelectorAll('[type="email"]'), function(emailElement) { | |
emailElement.addEventListener('invalid', function() { | |
var message = this.value + 'is not a valid email address'; | |
emailElement.setCustomValidity(message) | |
}, false); | |
emailElement.addEventListener('input', function() { | |
try{emailElement.setCustomValidity('')}catch(e){} | |
}, false); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment