Cab Date Validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:19 AM
Hai to Everyone,
I have one requirement the CAB date cannot be after planned start date ,I have already wrote the one onchange client script but it is properly not working when select the cab date in next month date then it is not working thta is only working on current month.
onchange:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 07:10 AM
Hi @siva44
Try the following onChange client script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var cab_epoch = getDateFromFormat(g_form.getValue('u_cab_date'), g_user_date_time_format);
var cabDate = new Date(cab_epoch);
var start_epoch = getDateFromFormat(g_form.getValue('start_date'), g_user_date_time_format);
var startDate = new Date(start_epoch);
if (cabDate > startDate) {
g_form.addErrorMessage("CAB date can't be after Planned start date");
g_form.setValue('u_cab_date', '');
} else if ((g_form.getValue('start_date') == '' || g_form.getValue('end_date') == '') && newValue != '') {
alert('Planned start and End date to be filled');
g_form.setValue('u_cab_date', '');
}
}
It it is not working, please confirm is your CAB Date field is Date type or Date/Time type.
Please mark my answer helpful and accept as solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 08:00 AM
The CAB Date field type id Date Type so Your script is not working AnveshKumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 10:21 AM
Hi @siva44
Try the following script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var cab_epoch = getDateFromFormat(g_form.getValue('u_cab_date'), g_user_date_format);
var cabDate = new Date(cab_epoch);
var start_epoch = getDateFromFormat(g_form.getValue('start_date'), g_user_date_time_format);
var startDate = new Date(start_epoch);
if (cabDate > startDate) {
g_form.addErrorMessage("CAB date can't be after Planned start date");
g_form.setValue('u_cab_date', '');
} else if ((g_form.getValue('start_date') == '' || g_form.getValue('end_date') == '') && newValue != '') {
alert('Planned start and End date to be filled');
g_form.setValue('u_cab_date', '');
}
}
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh