ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Mobile Number Length Validation in ErpNext

Use this code in Java script file
frappe.ui.form.on(‘Customer Login’, {
mobile_no: function(frm) {
if (frm.doc.mobile_no){
frappe.call({
method: “validate_mob_number”,
doc:frm.doc,
callback: function® {
}
});
}
}
});

"Next step is to add the codes return below in your Python file"

@frappe.whitelist()
def validate_mob_number(self):
if len(self.mobile_no) < 10:
frappe.msgprint(“Mobile number is invalid”)

frappe.ui.form.on(‘Customer_Login’, ‘validate’, function(frm) {
if (frm.doc.mobile_no.length<10) {
msgprint(‘The Mobile Number is invalid’);
Validate = false;
}
});

Try it