Skip to content

Instantly share code, notes, and snippets.

Created February 12, 2017 01:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment