Prevent user to select date before today on datepicker

Hi, is it possible to block dates or disable the dates on the datepicker. For example: in leave application module employee only able to apply their leave not less than 7 days before their leave. Thus is it possible to block 7 days on the datepicker from today.

1 Like

yes, it is possible

Could you please share some examples or references to achieve this. I could not find the way to this anywhere. Most of the thread leads to create a validation check instead of blocking the datepicker. Thank you.

please check this document


Thank you so much for your reply
Though i have a question.

is there a specific syntax i have to use to link it to the from_date?
for example employee cannot select any day before today.

minDate: new Date(2007, 1 - 1, 1)

When i try to implement the script it still does not block the other dates
this is my script
Thank you

minDate: frappe.datetime.get_today()

I have adjust but i can still choose other dates :frowning:

Try this

minDate: new Date(2007, 1 - 1, 1)

refresh: function (frm) {{
minDate: new Date(frappe.datetime.get_today()),

“date” is the field name

1 Like


I am trying to disable only one date on datepicker, but I am not getting any solution how to do it.

I read below document as suggested by @Misbah but I didn’t get anything.

This worked for me.

frappe.ui.form.on('Your Doc Type name', 'validate', function(frm) {
	if(frm.doc.your_field_name < frappe.datetime.nowdate()){
	    frappe.msgprint(__("You can not select past date in your_field_name"));
        frappe.validated = false
        frm.set_value('your_field_name', '')