Custom script in Material request form not working

I am trying to use this script in Material request form but it is not working :

frappe.ui.form.on(“Event”, “validate”, function(frm) {
if (frm.doc.schedule_date == get_today()) {
msgprint(__(“You can not select current date”));
throw “current date selected”
}
});

Please Help.

it should be like

rappe.ui.form.on("Material Request", "validate", function(frm) {
1 Like

Thanks for reply .
But still not working.
frappe.ui.form.on(“Material Request”, “validate”, function(frm) {
if (frm.doc.schedule_date == get_today()) {
msgprint(__(“You can not select current date”));
throw “current date selected”
}
});

@Shashank_Mishra
What is the error message your are receiving on console?

Please share your console error.

There is no error . Nothing happens .

@Shashank_Mishra validate method executes at the time of saving a doc. Put console and check wethere function is executting or not.

@saurabh6790 Function is not executing .

Pelase share, custom script screen shot.

@saurabh6790 Please have a look at screen shot:

@Shashank_Mishra, put console check console.log('validate date') before if loop.
Also check output of schedule_date and get_date.

@saurabh6790 , schedule_date value is empty . frm.doc.schedule_date is not picking up the value of field .
I checked the field name is correct .