I want some type of javascript to do like below
I have a text box to enter phone number
And its like this 111-111-1111
when a user start to type means when he types 111 then the “-” must come there automatically.
then again he types 111 “-” it should come automatically.
how can i do this???
please help
Thanks
With jQuery
You could use the masked-input plugin for jQuery: http://digitalbush.com/projects/masked-input-plugin/ There’s a demo on that page demonstrating specifically the format you illustrated here.
With MooTools
There’s also the iMask solution which is built off of Mootools: http://zendold.lojcomm.com.br/imask/
Without a Framework
And dFilter for those not using any framework, preferring pure javascript: http://javascript.internet.com/forms/dfilter.html
Else…
If you’re looking for a more thorough solution that doesn’t require Mootools, jQuery, or some other framework, you might find Typecast to be of interest: http://typecast.arapehlivanian.com/index.html