date field show error message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2024 02:14 AM
There is a "Date" field that is visible based on another field called "Request," which has three choices.
I need to implement validation on the Date field:
if a past date (earlier than today) is selected, an error message should appear, and the date field should be cleared. Additionally,
if the Request choice is changed, I do not want the previous error message to be displayed. However, after selecting a new date, if it is a past date, the error message should reappear.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2024 02:28 AM
Hi,
A simple UI policy with UI policy actions can resolve this requirement.
Mark Roethof has written a good article about it here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2024 04:34 AM
If you implement it in a client script:
※Replace "u_request_date" and "u_request_string" with the actual field names.
The onChang script of "request"
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var dateField = g_form.getValue('u_request_date'); // Replace 'your_date_field' with your actual Date field name
var today_date = new Date();
var today_date_str = formatDate(today_date, g_user_date_format);
// Check if the date is a past date
if (dateField && new Date(dateField) < new Date(today_date_str)) {
g_form.clearValue('u_request_date');
g_form.showErrorBox('u_request_date', 'Please select a future date.');
} else {
g_form.hideErrorBox('u_request_date');
}
}
The onChang script of "date"
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
g_form.hideErrorBox('u_request_date');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2024 09:56 PM
Hi @Community Alums you can achieve through Ui policy for reference check below link