Last active
January 14, 2020 06:44
-
-
Save Steamforge/e9a4a62369a4ebf992674e2f874bd906 to your computer and use it in GitHub Desktop.
Form Validation
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
<form id="signUpForm"> | |
<input type="email" id="emailField" required> | |
<button id="okButton" disabled>OK</button> | |
</form> | |
<script> | |
const signUpForm = document.getElementById('signUpForm'); | |
const emailField = document.getElementById('emailField'); | |
const okButton = document.getElementById('okButton'); | |
emailField.addEventListener('keyup', function (event) { | |
isValidEmail = emailField.checkValidity(); | |
if ( isValidEmail ) { | |
okButton.disabled = false; | |
} else { | |
okButton.disabled = true; | |
} | |
}); | |
okButton.addEventListener('click', function (event) { | |
signUpForm.submit(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line 12, you are assigning value to an undeclared variable. Aren't you missing
const
orvar
keyword at the beginning of the line?