Date field start and end date

Community Beginner ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

Hi There,

 

Is there are possibility I can setup  start date and end date to cordinate each other -- meaning, the end date should not be earlier than the start date.

 

Thank you.

TOPICS
PDF forms

Views

47

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

Yes, you can use a custom Validation script to reject the end date if it comes before the start date.

To help with this script we'll need to know the field names and what date format pattern they use.

However, keep in mind this won't stop the user from changing the start date to a later date once the end date was selected, so you might want to clear the latter when the former is changed.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

Hi Thank you.

 

For Field name it reads "TodayDate" and for date formate pattern "mm/dd/yyyy" so its 09/16/2022.

 

Thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

Is that the name of the end date field, or the start date?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

Hi there,

 

"Todaydate" is date field for start date and for  end date the field is called "Lastdate"

 

Thank you.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2022 Sep 18, 2022

Copy link to clipboard

Copied

As the custom Validation script of "Todaydate" enter the following:

 

this.getField("Lastdate").value = "";

 

As the custom Validation script of "Lastdate" enter the following:

 

if (event.value) {
	var startDateString = this.getField("Todaydate").valueAsString;
	if (startDateString=="") {
		app.alert("You must first enter the start date.");
		event.rc = false;
	} else {
		var startDate = util.scand("mm/dd/yyyy", startDateString);
		var endDate = util.scand("mm/dd/yyyy", event.value);
		if (endDate.getTime()<startDate.getTime()) {
			app.alert("The end date must not be earlier than the start date.");
			event.rc = false;		
		}
	}
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 21, 2022 Sep 21, 2022

Copy link to clipboard

Copied

LATEST

Hi there, 

Just want to say thank you for this, it worked perfectly and our teams like it.

 

Thanks again.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines