- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello,
I have a catalog client script that fails to trigger for validation.
Please help me get to the issue.
Variable on the catalog : date_of_the_event
Validation : This date should not be later than today.
The catalog client script is as follows
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) {
return;
}
var today = new Date();
var yyyy = today.getFullYear();
var mm = String(today.getMonth() + 1).padStart(2, '0');
var dd = String(today.getDate()).padStart(2, '0');
var todayString = yyyy + '-' + mm + '-' + dd;
if (newValue > todayString) {
g_form.showErrorBox(
'date_of_the_event',
'Date of the event cannot be later than today.'
);
g_form.setValue('date_of_the_event', '');
}
}
I have attached screenshot of the catalog client script.
Please let me know what AM I doing wrong here.
-Appreciate your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I found a better solution. Use catalog UI policy and used Run script to validate the Dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have chosen the type of the date_of_the_event as Date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I found a better solution. Use catalog UI policy and used Run script to validate the Dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
You could try this: