Leave Application date can not be past date!

Hello !!

I want to display only the date after today for leave application in the date picker.
Currently, I can submit a leave application for the Past date.

I have set a custom script, it worked, but It shows an alert after saving the Leave application.
Are there any solutions?

frappe.ui.form.on(‘Leave Application’, {
refresh(frm) {
if (frm.doc.from_date < get_today) {
msgprint(__(“You can not select this date”));
validated = false;
}
}
})

Hi @Meet_Patel,

Instead of using the Custom Script, you can just use this checkbox in Leave Settings under HR Settings.

Hope this helps.

2 Likes

Hello @michelle,

Yes, and is possible for an employee can able to apply for leave application before 15 Days?

Yes, the checkbox applies restriction on only backdated leaves. You can apply for leaves in advance without an issue. To keep a restriction of only 15 days in advance, you will have to write a custom script. However, if there is no such restriction, then there is no need for custom script.

Hope this helps.

Yes, @michelle, to keep the restriction of 15 Days in advance I wrote a custom script, it shows a pop-up that you can not select this date. but still, the employee can save leave application, and while changing leave application status from Leave approver Account again it shows the same pop-up but Approver still approves and submit leave. So is it possible to restrict approval or submission of that kind of leaves?

@Meet_Patel did you get any solution for this?? can you please share that

Hello @Nidhi_Singh

I think this will work.

frappe.ui.form.on(‘Leave Application’, {
refresh(frm) {
// your code here

   if (frm.doc.from_date < get_today) {
        frappe.msgprint(__("Can Not Select Date"));
        frappe.validated = false;
    }

}

})

thanks @Meet_Patel

1 Like