tags:

views:

536

answers:

1

i have a textbox wherein the user is required to enter amount.i want to know the way to put a validation on the key press event so that the user might not enter more than one decimal point i.e user is allowed to enter values like 99.999 only not like 99...22 plz suggest some property or method to do this??

+1  A: 

Regular expressions are a good way to do that!

Check out:

http://en.wikipedia.org/wiki/Regular_expression

http://www.regular-expressions.info/dotnet.html

This might be the regex you are looking for:

[0-9]+(\.[0-9]*)?
Chris
its not working..still i m able to enter more than one decimal point..
post your code...
Chris
its done now..i hv used the isnumeric function.bt i m getting another problem..i want the user to enter as many digits before decimal point but only two digits after the decimal point..like 123.45 or 12.67 or 4566.67?how to do that?
regex: [0-9]+(\.[0-9][0-9])?
Chris
or consider using a masked textbox
Chris
plz tell me how to apply the expression???