2

I want the users to fill the Telephone field in a formatted way, for example, the format in my country is 03XX1234567. How can I set the field to only accept a number in this format else give an error?

2

1 Answer 1

4

Please check below for an example for custom validation (Accepting only numbers and minimum number count should equals or above 10)

Assign the below class to the telephone field "validate-phone"

Then add the below script in that page

Validation.add('validate-phone','Dashes or spaces are not accepted',function(the_field_value){
    if((the_field_value.length >= 10) && (!isNaN(the_field_value)))
    {
        return true;
    }
    return false;
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.