Created
November 5, 2018 02:08
-
-
Save somoza/67e5e47c4541a039c49f7d8b5c423fe0 to your computer and use it in GitHub Desktop.
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
document.addEventListener("DOMContentLoaded", function() { | |
var elements = document.getElementsByTagName("INPUT"); | |
for (var i = 0; i < elements.length; i++) { | |
elements[i].oninvalid = function(e) { | |
e.target.setCustomValidity(""); | |
if (!e.target.validity.valid) { | |
e.target.setCustomValidity("This field cannot be left blank"); | |
} | |
}; | |
elements[i].oninput = function(e) { | |
e.target.setCustomValidity(""); | |
}; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment