Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

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.
0
sweoff
Asked:
sweoff
  • 3
  • 2
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
co5moCommented:
This should work:

^((([0-9]|1[0-9]|2[0-3])((\.0+)*|(\.250*)|(\.50*)|(\.750*)))|((\.250*)|(\.50*)|(\.750*))|(24)|(24.0))$
0
 
sweoffAuthor Commented:
PERFECT!
0
 
farzanjCommented:
Did you try my one again??
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now