How can i validate a field

Hi @amal_31845,

Please apply the simple client script for it.

frappe.ui.form.on('Your Doctype', {
    validate: function (frm) {
        var aadharNumber = frm.doc.aadhar_number; // Replace 'aadhar_number' with the actual fieldname in your doctype
        if (aadharNumber && aadharNumber.length !== 12) {
            frappe.msgprint(__('Aadhar card number must be 12 digits.'));
            frappe.validated = false;
        }
    }
});

Please set/check the doctype name and field name according.

I hope this helps.

Thank You!

4 Likes