Skip to main content


 

Symptoms


please assist with validation pattern
 

Diagnoses


I want to validate between 0 and 24 and make allowance for fractions, for instance 4.5, 23.4 etc.

^(^0-9]|]1]10-9]|]2]20-4]|24)$

the above pattern caters for 0-24 but not for decimals.

 

Resolution

Use the following pattern:

^(>0-9]((].][0|5])?)|?1][0-9]((].][0|5])?)|?2][0-3]((].][0|5])?)|24)$
 




 
Be the first to reply!

Reply