Saves even if validation is failed

Hi all ,
so I made a simple validation script. The script runs fine and throws an error message but saves after the validation is failed .am i doing something wrong.

frappe.ui.form.on('Farms', {
	refresh(frm) {
        if (frm.doc.grow_area_uom > frm.doc.farm_area_uom){
            frappe.msgprint(__("Grow Area cannot be greater than Farm area"));
            frappe.validated = false;
            return false;
        }
}});

Hi @Anjan_Dev,

Please apply it.

frappe.ui.form.on('Farms',  'validate',  function(frm) {
    if (frm.doc.grow_area_uom > frm.doc.farm_area_uom) {
        msgprint('Grow Area cannot be greater than Farm area');
        validated = false;
    } 
});

Reload and check it, please.

Thank You!

hi @NCP
thanks for replying.
just tried your code. there was no change in the op

Try to use frappe.throw instead of frappe.msgprint.

Thanks @Pawan . It worked :blush: