Created
April 5, 2018 04:28
-
-
Save dave-martinez/77f4517e535e27a8f0e416953bbcff90 to your computer and use it in GitHub Desktop.
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
// Kahit tanggalin mo na din yung pattern since nag JS validation na naman | |
<input type="text" name="contact" id="contact" maxlength=11 onchange="validateContact()"> | |
function validateContact() { | |
// Palitan mo nalang yung id sa getElementById | |
var contactLength = document.getElementById('contact').value.length; | |
var submitButton = document.getElementById('theSubmit'); | |
if(contactLength == 7 || contactLength == 11) { | |
submitButton.disabled = false; | |
} else { | |
alert('Invalid number length'); | |
submitButton.disabled = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment