Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// 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
You can’t perform that action at this time.