Created
November 20, 2015 21:45
-
-
Save o-nasteka/cf87b441f78935a86885 to your computer and use it in GitHub Desktop.
required input Safari
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
<script type="text/javascript"> | |
function checkForm(){ | |
var forms = document.getElementsByTagName('form'); | |
for (var i = 0; i < forms.length; i++) { | |
forms[i].noValidate = true; | |
forms[i].addEventListener('submit', function(event) { | |
//Prevent submission if checkValidity on the form returns false. | |
if (!event.target.checkValidity()) { | |
event.preventDefault(); | |
//Implement you own means of displaying error messages to the user here. | |
alert('Please, fill the form.'); | |
} | |
}, false); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment