Skip to content

Instantly share code, notes, and snippets.

@dave-martinez
Created April 5, 2018 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave-martinez/ca7443fce4852668322b1ae07f5d0608 to your computer and use it in GitHub Desktop.
Save dave-martinez/ca7443fce4852668322b1ae07f5d0608 to your computer and use it in GitHub Desktop.
function validateContact() {
// Baguhin mo lang onti to
var contact = document.getElementById('contact').value;
var contactLength = contact.length;
// Dagdag mo tong variable na to, regex tester
var contactIsDigit = /^\d+$/.test(contact);
// Tapos may last na condition
if((contactLength == 7 || contactLength == 11) && contactIsDigit) {
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