Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
I have a code block with restricts the user to select past dates, but I'm not able to restrict the past time. For example, my current date and time is 2025-12-11 01:30:00. I want the user to be restricted to pick the time of 2025-12-11 01:25:00, which is the same day but a past time.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
var value = g_form.getValue('snapshot_creation_time');
if (!value)
return;
// Convert the snapshot_creation_time to a time object
var snapshotTime = new Date(value);
var currentTime = new Date();
// check if snapshot creation time must be in future
if (snapshotTime <= currentTime) {
g_form.showFieldMsg('snapshot_creation_time', 'Snapshot creation time must be in the future.', 'error');
g_form.setValue('snapshot_creation_time', '');
}
}
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13 hours ago
I didn't know that we could do this with UI Policy.
I just made it as shown below according to my requirements. Thanks!
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
It works for the date, it again fails when I choose a future time on the same day.