Validation Expression

I need to build a validation expression for .NET that will accept whole numbers up to max of 24 or quarters. examples:

1 < Should Work
24.50 < Should NOT work because its over the whole 24
1.25 < Should work
.35 < Should NOT work because its decimal is not within a quarter
.50 < Should work
23.50 < Should Work
23.87 < Should NOT work because its decimal is not within a quarter
17.75 < Should Work

I currently have the current expression:
^([0-9]|1[0-9]|2[0-4])((\.0+)*|(\.250*)|(\.50*)|(\.750*))$

But... this expression is falling short of what i need.
sweoffAsked:
Who is Participating?
 
co5moCommented:
This should work:

^((([0-9]|1[0-9]|2[0-3])((\.0+)*|(\.250*)|(\.50*)|(\.750*)))|((\.250*)|(\.50*)|(\.750*))|(24)|(24.0))$
0
 
farzanjCommented:
Try this:

^(?:[0-1]\d|2[0-3](?\.(?:25|50|75))?)|24$

Open in new window

0
 
sweoffAuthor Commented:
ASP.NET did not like the syntax of that Expression. I get the following error message:

Microsoft JScript runtime error: Unexpected quantifier
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
farzanjCommented:
Try this:
^(?:[0-1]\d|2[0-3](?:\.(?:25|50|75))?)|24$

Open in new window


OR
^([0-1]\d|2[0-3](\.(?:25|50|75))?)|24$

Open in new window

0
 
sweoffAuthor Commented:
PERFECT!
0
 
farzanjCommented:
Did you try my one again??
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.