I'm not sure there is a way to do that using ASP.NET alone, but you can do
it reasonably easily using JavaScript's onkeypress event. I have written a
simple function that allows you to have TextBox Controls accept only certain
characters or sets of characters (such as uppercase, lowercase, numbers,
hexadecimal, etc.) to make it easier to do what you are trying to do. If you
would like me to send you the code for this function (it is written using
VB.NET), let me know (I don't like sending attachmements without people
asking for them). Good Luck!
You can use the RegularExpressionValidator to just accept digits. Look at
this for example http://aspnet101.com/aspnet101/tutorials.aspx?id=11. It's a
bit cleaner than the JavaScript keyup/keydown solution. However you get a
different result as the default validator usually fires on a different event
(like the submit of a form for example).
Richard
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.