Contact Number should not be less than or more than 10 Characters. It should be always equal to 10

We want to set the length to exactly 10. For example, someone puts a 9-digit number or 11 it should not be allowed.

How to mange this.

You can use this client script

frappe.ui.form.on('YourDoctype', {
    validate: function(frm) {
        var phone_field = frm.doc.phone        
        if (frm.doc[phone_field] && frm.doc[phone_field].length !== 10) {
            frappe.msgprint(__("Phone number must be 10 digits long."));
            frappe.validated = false;
        }
    }
});

Use the same Script but now working.

It is got saved even after putting the 3 Digits

Sorry it is not working- Misspelled in earlier statement