Regular Expression for Percentage field [Resolved]

Posted by Mutturaj under C# on 2/28/2013 | Points: 10 | Views : 13418 | Status : [Member] | Replies : 2
Hi,

I want to validate a Percentage field. It can allow any value between 0 to 100(Even decimal numbers also).

Ex : 10, 73.56, 86.5, 100 etc

What Regular Expression I have to use for this.




Responses

Posted by: Somu475 on: 2/28/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

Try using this..

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

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


-Somu

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

Posted by: Sakthi.Singaravel on: 2/28/2013 [Member] Silver | Points: 25

Up
0
Down
Regex.Match(percentag, "^[1]{0,1}[0-9]{1,2}\.\d{1,}$")


Regards,
Singaravel M

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

Login to post response