End date can't be prior to start date | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Pulkit_Jain_
Pulkit_Jain_Accepted solution
Employee
Oct 21, 2022 4:58 AM UTC

@reluctantprogrammer 

You can write a simple validation on the end date field exit as below:

 form1.#subform[0].DateField2::exit - (JavaScript, client)
  var startDate = new Date(DateField1.rawValue);
  var endDate = new Date(DateField2.rawValue);   
      if(startDate  > endDate )
{
 xfa.host.messageBox("End Date:"+ endDate +"should be greater than Start Date:"+ startDate);
}

 

You can add more validations to this check to ensure startDate is not null, and any change in the date fields will retrigger validations etc.

Hope this helps!

 

2 replies

Pulkit_Jain_
Pulkit_Jain_Accepted solution
Employee
Oct 21, 2022 4:58 AM UTC

@reluctantprogrammer 

You can write a simple validation on the end date field exit as below:

 form1.#subform[0].DateField2::exit - (JavaScript, client)
  var startDate = new Date(DateField1.rawValue);
  var endDate = new Date(DateField2.rawValue);   
      if(startDate  > endDate )
{
 xfa.host.messageBox("End Date:"+ endDate +"should be greater than Start Date:"+ startDate);
}

 

You can add more validations to this check to ensure startDate is not null, and any change in the date fields will retrigger validations etc.

Hope this helps!

 

Translate
ReluctantProgrammer
Level 4
Oct 21, 2022 4:35 PM UTC

Thanks for your help!

 

Translate