Only digits, the digit may be decimal (regular expression)

.net, asp.net, regex, validation

Solution

You can use `RegularExpressionValidator` and here is Validation Expression `ValidationExpression="[0-9]*\.?[0-9]*"`

Finally it will be look like...

 <asp:RegularExpressionValidator ID="rgx" ControlToValidate="txtControl" runat="server"
      ErrorMessage="*" Display="Dynamic" ValidationExpression="[0-9]*\.?[0-9]*"></asp:RegularExpressionValidator>

Problem

in my web application i want to validate that user can enter only digits and the digit may be a integer or decimal how can i write the regular expression for this. help me thank you

Original source