I am attaching an asp.net textbox image
I want my textbox should have two brackets and one dash, for the numbers like (92)42-83823823, i want brackets and dash to be non-editable, and i dont want to use ajax control toolkit or some component other than asp.net text box control or jquery, is there some way to tackle such situation.
The jQuery Masked Input Plugin does exactly what you want. For a phone number, the code to mask the
inputelement would look something like this:where
phoneis theidof theinputelement.Either way, client-side code is definitely the way to do this. From the server-side code’s perspective, it just wants the resulting value (and will re-validate it, of course). The client-side code is what’s creating the more dynamic user experience.
Edit: I suppose this violates your requirement to not use “some component other than asp.net text box control.” There’s a good reason for that, though. The ASP.NET
TextBoxby itself doesn’t have this functionality. You can write code to make it happen, and it will be JavaScript code. Or, you can use code that’s already been written and continue about the more meaningful parts of your application 🙂