I have a text box and it says “Phone:” as the standard here for phone number is (XXX)-XXX-XXXX
I’d like to have a javascript that automatically puts my numbers into that format if it’s not in that format, so if you typed 9993334444 then it would change it automatically on the fly as I’m typing to (999)-333-4444 I have looked around Google for Javascript Phone Regex to no success, maybe a Regex isn’t what I’m looking for?
I have a text box and it says Phone: as the standard here for
Share
you want to add an onkeyup event with a regex like
Check out http://jsfiddle.net/R8enX/
EDIT: realized I missed a digit on the last group of numbers, the jsfiddle will only work (properly) with 3 digits in the last group