Mar 26, 2010

TextBox which accepts only numbers validation

 In this example, I'll show you how to extend ASP.NET textbox so
that it accepts only numbers as input. Users will not be allowed to enter
anything other than numbers in the textbox.

 I have added a RegularExpressionValidator to validate user entries
on the server side. It uses the following expression:
(^[-]?[1-9]\d+$)|(^[-]?[1-9]$)|
(^0$)|(^[-]?[1-9]\d+\.\d$)|(^[-]?[0-9]\.\d$)

No comments:

Post a Comment