- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 05:51 AM
Hi all,
I have a catalog client script to prevent users from selecting a date in the past. But it is not fully working.
It now stops me from selecting any date, and error appears. past or future date.
Below is my script on a onChange client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//current date
var currentDateObj = new Date();
var currentDateStr = formatDate(currentDateObj, g_user_date_format);
var currentDateNum = getDateFromFormat(currentDateStr, g_user_date_format);
var startDateNum = getDateFromFormat(newValue, g_user_date_format);
if (startDateNum < currentDateNum) {
g_form.addErrorMessage("Date cannot be in the Past");
g_form.clearValue("day_month_year_start_time");
return false;
}
}
please advise
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 05:57 AM
Hi @Khalnayak ,
Please use my below working Scripts,just replace your variables.
onChange Catalog Client Script:-
1) Client Script for Future Date Validation:-
2) Past Date Validation:-
3) Common Client Callable Script Include:-
4) Script Include Code;-

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 05:57 AM
Hi @Khalnayak ,
Please use my below working Scripts,just replace your variables.
onChange Catalog Client Script:-
1) Client Script for Future Date Validation:-
2) Past Date Validation:-
3) Common Client Callable Script Include:-
4) Script Include Code;-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 05:59 AM
Thanks, please can you copy paste the scripts here too so I can copy it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 06:15 AM
Kindly write the code from the screenshot as my instance is offline right now @Khalnayak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 04:45 AM
Hi Sandeep, i have setup as above but it does not work