Reputation: 11469
How can I build a regular expression that checks that it must be a number between 0 - 999999999.
Opted for the range validator.
Upvotes: 1
Views: 246
Reputation: 62990
Assuming you would want to match numbers that don't start with zero:
Then [1-9]\d{0,8}
should do it.
Upvotes: 2
Reputation: 13135
If you are trying to validate this inside a <asp:RegularExpressionValidator>
then you need to do the same as has been hinted at so far in this thread but you also need a ^ and $ on each end so that it doesnt allow other characters to be added in around it.
^\d{1,9}$
Upvotes: 1
Reputation: 98868
If you mean control the number which range, can use rangevalidator
MaximumValue Specifies the maximum value of the input control
MinimumValue Specifies the minimum value of the input control
<asp:RangeValidator
ControlToValidate="tbox1"
MinimumValue="1"
MaximumValue="999999999"
Type="Number"
EnableClientScript="false"
runat="server" />
Upvotes: 1
Reputation: 10080
You could do this:
\d{1,9}
\d
- digit{1,9}
- 1 to 9 repetitionsUpvotes: 1
Reputation: 27536
The simplest thing would be [0-9]{1,9}
That will accept all integers between 0 - 999999999.
If you want decimals or scientific notation, that can be done too though it's trickier and you might also want to look into some other tool to validate the number value.
Upvotes: 5