Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 10:57 PM
sample onChange client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var start = g_form.getValue('variableName');
g_form.hideFieldMsg('variableName'); // give here your variable name
var minutes = 120; // 120 mins is 2 hours
var dateGiven = new Date(getDateFromFormat(start, g_user_date_time_format)).getTime() + minutes * 60000; // add 120mins to date and then compare
var nowTime = new Date().getTime();
if (dateGiven < nowTime) {
g_form.showFieldMsg('variableName', 'Please select date/time after 2 hours from now', 'error');
g_form.clearValue('variableName');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader