ERPNEXT leave application calendar

hello,
how to set the from to dates in leave application to disable past dates and enable only date of today ? thanks

Hi @AntoniosKamel,

You can add validate using the client script so please apply the client script for the Leave Application.

frappe.ui.form.on('Leave Application', {
	validate: function(frm) {
		if (frm.doc.from_date < get_today()) {
            msgprint('You can not select past date in From Date');
            validated = false;
        }
	}
});

When the user saves the leave application then it will throw the error and the user can’t save the leave application.

I hope this helps.

Thank You!

the message

msgprint('You can not select past date in From Date');

does not appear

how to fix it?

Hi @aqilmujahidiin,

Please check the video.

I hope this helps.

Thank You!

1 Like

not working for this version

image

I even can’t click the save button

Hmm :thinking:

Please try it.

frappe.ui.form.on('Leave Application', {
    validate: function(frm) {
        if (frm.doc.from_date < frappe.datetime.get_today()) {
            frappe.throw('You cannot select a past date in From Date');
        }
    }
});

I checked the above script and I worked from my end.

Thank You!

2 Likes

nice, this code is working

thanks for the help and guidance it worked