Write mobile number validation : System should be allow only 10 digit mobile number

praveenaaa
Giga Explorer
Write mobile number validation : System should be allow only 10 digit mobile number  
          If customer enter 9 digits or 11 digits(System should through Error Message on the form)
          Message is : Please enter 10 digit mobile number only 
1 REPLY 1

Samaksh Wani
Giga Sage
Giga Sage

Hello @praveenaaa 

 

You need to write a onChange Client Script :-

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var reg = /^[0]\d{10}/;
    if (!reg.test(newValue)) {
        g_form.setValue('phone_number_field_name', '');
        g_form.showFieldMsg('phone_number_field_name', 'Phone number should start with 0 and be 11 digits', "error");
    }
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh