function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gopal ChatGopal Chat 

How to write a validation rule for time formate HH:MM - HH:MM for a text field

Best Answer chosen by Gopal Chat
Akshay_DhimanAkshay_Dhiman
Hi Ragav,

Try this rule its working fine

NOT
(
 REGEX
 (
 FieldApiName,
 "[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1} - [0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}"
 )
)
 
 Thanks 
 Akshay

All Answers

Rahul Jain 169Rahul Jain 169
NOT( 
REGEX(Text Field, "[0-2][0-3]:[0-5][0-9]-[0-2][0-3]:[0-5][0-9]") 
)
Gopal ChatGopal Chat
this is ony for HH:MM i want HH:MM-HH:MM
Akshay_DhimanAkshay_Dhiman
Hi Raghav,
Please use this, hope this will helpful:
NOT(REGEX(Field__c , "[\\d]{1,2}:[0-5]{1}[0-9]{1}"))

Thanks 
Akshay Dhiman
Gopal ChatGopal Chat
Hi Akshay 
I think your answer is for HH:MM formate but my requirments is HH:MM-HH:MM(first is start Start time and second for end time)
Akshay_DhimanAkshay_Dhiman
Hi Ragav,

Try this rule its working fine

NOT
(
 REGEX
 (
 FieldApiName,
 "[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1} - [0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}"
 )
)
 
 Thanks 
 Akshay
This was selected as the best answer
Gopal ChatGopal Chat
Thanks Its working fine