Demo : http://jsfiddle.net/tmS3V/171/
[Quiet Possible the Link may not work! Its a fiddle]
Disclaimer: Well this project is not technically a js file that you can include on your pages but just a snippet that can be used for formating phone numbers and hence the name!
Requirements: jquery 1.7.2 and above [tested] An html page with a line of html code that adds the phone number text field [included in the js file though at the top :)]
Directions to Use: Just copy paste the javascript code and place it either internally or externally on your page, coupling along with the appropriate text-field name in this case "phone-number".
Exlpanation: This is the need of most of the telephone number fields on most of the registration web pages that you generally find. Personally I didnt get a code which used to do this so I created this. ©AnandPadmakarShenoy muahaha
The concept that I used here is whenever a key is pressed on the text-box you stop to see the position of the element[with the help of the global_var] and accordingly insert a character by stopping the default action of the keypress ,performing operation and then returning the control to textbox.
Usage Policies: Just use it and remember me and and if you are generous bless me! Go Open Source !