Custom Script not working for Date validation

Hi All,

To validate the Date in Purchase order, I wrote a custom script like this

frappe.ui.form.on(“Purchase Order”, “validate”, function(frm){

if(frm.doc.transaction_date < frappe.datetime.get_today()){
frappe.msgprint(__(“You can not select past date in From Date”));
frappe.validated = false;
}

});
But it doesn’t work. It shows the message and document is saved in past date. It should not save with past date. Kindly help me.

@Racer_Aravind,

Just check on my instance and the custom script seems to work fine, can you please share the ERPNext & Frappe app versions?

Here is a screenshot.

@makarand_b
Awaiting for your reply.

try this,

frappe.ui.form.on("Purchase Order", {
	validate: function(frm) {
		if(frm.doc.transaction_date < frappe.datetime.get_today()){
			frappe.msgprint(__('You can not select past date in From Date'));
			frappe.validated = false;
		}
	}
})

working on following versions

image