Regular expression for validating numbers

The Validation Expression attribute has a button next to it, and if you click it, you will gain access to some default expressions, delivered by the ASP.

Hey, I'm looking for the formula for a validator that will accept numbers only. I read this post: But, this examples stills allows spaces. use this ^[0-9] $ You can also use compare validator for this with the following properties: Operator="Greater Than Equal" Type="Integer" Value To Compare="0" // or whatever value you want Or You can use this expression: Validation Expression="^[0-9]*$" hi taffylewis, check this post here i explained clearly how to restrcit user to enter only numbers in textbox using javascript.

You need TWO validator controls to ensure only numeric values are entered.

Are you trying to craft a regular expression for an input to validate it is a numeric value?

Decimals are numerics so you don't need to check for decimals specifically. To allow numbers with an optional decimal point followed by digits.

A digit in the range 1-9 followed by zero or more other digits then optionally followed by a decimal point followed by at least 1 digit: i.e.

Try switching to Design view and select the Regular Expression Validator on your page.

Now have a look in the Properties tab of Visual Studio.

regular expression for validating numbers-80regular expression for validating numbers-61

It's make the regex to be 4 chars longer, but fix the problem for you also.If you don't feel like learning Regular Expressions, but still feel like using this validator, have a look around the Internet.You can find many pre-made expressions out there, which can be very useful to you.Hi Team, How to validate the "number field" for example: In my form i have Enter No.of Items Text box, in that user should enter only numeric values only not any characters or text or special characters.

Leave a Reply