
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 02:53 AM
I need to compare a date variable with today's date but I can seem to convert the date variable to a date format;
var selectedDateStr = Date.parse(newValue);
var selectedDateNum = getDateFromFormat(selectedDateStr,g_user_date_time_format);
var today_dateStr = formatDate(new Date(), g_user_date_time_format);
var todayDateNum = getDateFromFormat(today_dateStr, g_user_date_time_format);
if(selectedDateNum < todayDateNum) {
g_form.showErrorBox('pick_up_date','Expected date cannot be less than today date (selectedDateNum = ' + selectedDateNum + ' | todayDateNum = ' + todayDateNum +' | pick_up_date = ' + pick_up_date + ' | selectedDateStr = ' + selectedDateStr + ')',true);
} else {
g_form.hideFieldMsg('pick_up_date',true);
}
ShowErrorBox:
Expected date cannot be less than today date (selectedDateNum = 0 | todayDateNum = 1715852782000 | pick_up_date = [object HTMLDivElement] | selectedDateStr = NaN)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 11:25 AM
You may want to take a look at this instead of using a script.
Or this one where you would use a script include called from a client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 11:25 AM
You may want to take a look at this instead of using a script.
Or this one where you would use a script include called from a client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 04:51 AM
Thanks, I needed to do it indeed in a script include instead of doing it in the client script.