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?
-
Which file to add this validation to?– Waqas ZiaJun 19, 2019 at 15:30
-
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review– Shoaib MunirJun 19, 2019 at 16:53
1 Answer
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;
});