I have a text box that a user can optionally enter data into. The data is all digits and up to 10 digits should be entered. As the user is typing the data into the textbox, I need to add a dash after the first two digits and then after the next four digits after that. So, the data should appear like this: ##-####-####
Can this be done from a javascript or is there some other way to do this? I found some code to call a javascript from the on keyup or keypress event, but that only formats the data after it has been entered completely. I need it to format as the user is typing the data into the textbox.
Thanks.