Regular Expression to get only the decimal value

Posted by .Netlearner under ASP.NET on 7/26/2012 | Points: 10 | Views : 3946 | Status : [Member] | Replies : 7
Hello All,

I want my text box to get only the decimal values,

eg.10.00,100.25,500.00

Even its a whole number i want it to denote as 10.00

what validation expression should i use in the regular expression validator ?




Responses

Posted by: Oswaldlily on: 7/27/2012 [Member] Starter | Points: 25

Up
0
Down
ValidationExpression="[0-9]+(\:[0-9]*)?"

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Somasundaram on: 7/27/2012 [Member] Starter | Points: 25

Up
0
Down
Validation Expression:

^[0-9]*(\.[0-9]{1,2})?$

EG: 122.21 (Accepts only 2 digits after decimal point)


Regards,
Somasundaram

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 7/27/2012 [Member] Starter | Points: 25

Up
0
Down
Hello All

thanks for your answers,i tried both and its working but now the problem is after the error message eventhough i entered the correct value the error message is still present.If i enter the correct value in the first attempt its getting inserted if i tried with wrong value and then try to insert the correct value its not getting inserted due to this validation error.

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 7/27/2012 [Member] Starter | Points: 25

Up
0
Down
@.Netlearner.
Then its a gridview binding problem..check while insertin correct value ,whether correct value passes

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 7/27/2012 [Member] Starter | Points: 25

Up
0
Down
Am not using a grid view its just a textbox.i Dont know why it occurs like this

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Somasundaram on: 7/27/2012 [Member] Starter | Points: 25

Up
0
Down
hi.,

Cant understand your Problem can u explain in detail with example...


Regards,
Somasundaram

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 7/27/2012 [Member] Starter | Points: 25

Up
0
Down
@.NetLearner
Ok fine.In dt case u ll be passing textbox value as arguments to insert it..
So check here whether correct value passes..


.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response