- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 12:46 PM
I have a requirement where one date field, End Date [endDate], should not start before the other date field on my form, Start Date [startDate].
I am trying to write a Catalog Client Script as this is for a Record Producer, but am having difficulty writing this script. Can anyone assist me with this issue?
Thank you,
Kevin E
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 12:58 PM
Hello Kevin
Try this.
Should be a Onsubmit client script
function onSubmit() {
//Type appropriate comment here, and begin script below
var startDate = g_form.getValue("start_date");
var endDate = g_form.getValue("end_date");
if (startDate == "" || endDate == "")
return;
if(startDate == endDate){
g_form.addErrorMessage('Start date must be before end date');
return false;
}
var result = compareDates(startDate, endDate);
if (startDate > endDate) {
g_form.addErrorMessage('Start date must be before end date');
return false;
}
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 12:58 PM
Hello Kevin
Try this.
Should be a Onsubmit client script
function onSubmit() {
//Type appropriate comment here, and begin script below
var startDate = g_form.getValue("start_date");
var endDate = g_form.getValue("end_date");
if (startDate == "" || endDate == "")
return;
if(startDate == endDate){
g_form.addErrorMessage('Start date must be before end date');
return false;
}
var result = compareDates(startDate, endDate);
if (startDate > endDate) {
g_form.addErrorMessage('Start date must be before end date');
return false;
}
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 01:57 PM
I appreciate the quick response. I will give this a try and let you know if it works
Thank you,
Kevin E

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 04:53 PM
Hi Kevin,
We have a solution for this in our instance but it is quite elaborate and not sure if it needs to be this elaborate but here it goes:
We have an include script that has a bunch of functions within it, the important one is 'getDateTimeDiff'
the code for it is here:
We call that function back in a client script and this is how we have the client script set up:
The UX you get from this is when a user selects a date that is before the start date, it throws an error with the text you see in the Client script towards the bottom, when they click ok on the error message it clears the field so no value is stored.
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2017 01:47 PM
Thank you for your post as well Stephen! I used the first option and it worked. I will keep what you provided in my back pocket for later usage if needed.
Kevin