regular expression to allow value between 1 to 5 .

Posted by Sharmagoldi781 under JavaScript on 11/14/2014 | Points: 10 | Views : 1296 | Status : [Member] | Replies : 2
i need to bulid a expression to allow values in textbox between 1 to 5. and decimal numbers should also be allowed between 1.0 to 4.99.but decimal numbers should not be allowed with 5 because then that value will exceed 5 .




Responses

Posted by: Bandi on: 11/15/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Try this

^([1-4]{1}(\.\d{1,2})?|5(.0{1,2})?)$


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

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

Posted by: vishalneeraj-24503 on: 11/17/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi,
simply you can validate as:-
[0-9]{1,5}


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

Login to post response