Created
February 12, 2017 01:49
-
-
Save asimmittal/041fa3432b5ff11482b90b23303ca175 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/******************************************************* | |
* 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