Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*******************************************************
* setupPhoneFields
* Now let's rig up all the fields with the specified
* 'className' to work like phone number input fields
*******************************************************/
function setupPhoneFields(className){
var lstPhoneFields = document.getElementsByClassName(className);
for(var i=0; i < lstPhoneFields.length; i++){
var input = lstPhoneFields[i];
if(input.type.toLowerCase() == "text"){
input.placeholder = "Enter a phone (XXX-XXX-XXXX)";
input.addEventListener("keydown", onKeyDown);
input.addEventListener("keyup", onKeyUp);
}
}
}
//MAIN
setupPhoneFields("phoneNumber");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment