Past Date on Date field should thrown an error near field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 04:22 AM
Hi Experts,
My requriement is I have only 1 date field whenever i select past date from today it should show field error message. I tried using UI policy but only for 1st time it's working,if i keep on checking again and again the error is not occuring.
Please somebody help me what is the best approach for this?
Regards,
Gayathri
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 04:47 AM
Hi Gayathri,
You can use this script in UI policy
condition :
yourdateFieldname before today.
function onCondition() {
g_form.clearValue('u_date');
g_form.showErrorBox("u_date","Please select future date and time",true);
//or u can put following line.
//alert("Please select future date and time");
}
Please mark correct/helpful based on impact.
Regards,
Aniket Sawant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 05:06 AM
I tried this but i was facing some issue so through client script we can achieve.
can u achieve the same using client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 05:00 AM
Hi,
You can use onChange client script on the required field and write the code to check if the user is entering the past date.
Please mark correct/helpful based on impact.
Regards,
Bharath kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 12:27 AM
Hi Gayathri,
Create onChange Client Script on Field u want to change.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var currentDate = new Date(); //Current Date
var selectedDate = new Date(g_form.getValue('u_date_field')); //Date field value
if (currentDate.getTime() >= selectedDate.getTime()) {
//Past Date on Date field should thrown an error near field
g_form.showFieldMsg('You can not select a Past Date');
return false;
}
}
Shakeel Shaik 🙂