Ankur Bawiskar
Tera Patron
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 01-22-2025 04:27 AM
Consider a requirement to validate if the user selects a time in the date/time variable between 11 AM and 4 PM.
You can use the onChange catalog client script with the following logic. It handles for every timezone.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg('my_datetime');
var myDate = new Date(getDateFromFormat(newValue, g_user_date_time_format));
var hourValue = myDate.getHours();
if (hourValue > 11 && hourValue < 16) {
// valid
} else {
g_form.showFieldMsg('my_datetime', 'Time should be between 11am to 4pm', 'error');
}
}
This checks the time is between 11am to 4pm based on logged in user timezone.
Output: I selected GMT & then selected Los Angeles time zone and it gave me the error based on requirement.
Comments
Appu
Tera Guru
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
02-05-2025
01:38 AM
@Ankur Bawiskar
I hava a requirement where date/time variable when selected should be adjusted according to UTC time zone always.
Please provide a solution
Thanks in advance