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.
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.
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.
cur_frm.fields_dict.from_date.datepicker({
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
Try
minDate: frappe.datetime.get_today()
Try this
cur_frm.fields_dict.from_date.datepicker.update({
minDate: new Date(2007, 1 - 1, 1)
});
refresh: function (frm) {
frm.fields_dict.date.datepicker.update({
minDate: new Date(frappe.datetime.get_today()),
});
},
“date” is the field name
Hello,
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', '')
}
})