1
This is what I’ve got so far:
public static function ValidaFone($RegeEx)
{
$RegeEx = preg_match('/^[0-9]{9,11,13}$/',$RegeEx);
........code.....
}
1
This is what I’ve got so far:
public static function ValidaFone($RegeEx)
{
$RegeEx = preg_match('/^[0-9]{9,11,13}$/',$RegeEx);
........code.....
}
1
Phone traces can only be present in specific positions, right?
/^([0-9]{5}(-| )?[0-9]{4})$/
This regex says the following:
You can refine the expression to not allow, for example, zero-initiated phone numbers, or to include more snippets like area code.
To understand any regular expression in JS, recommend the site http://regex101.com/. You can put an expression there and the site explains the excerpts.
Thanks @Renan thinking so have you given me an idea this way not valid case user also enter the code of the country that would be two more character but gave me a good idea for this worth
Browser other questions tagged php regex
You are not signed in. Login or sign up in order to post.
Possible duplicate of Validate phone number with optional ninth digit
– Woss
What is the expected format?
– rray
first time I use regex as I do to say that the ninth digit in case the dash may be optional ?
– Pedro Amorim
The dash is something 'optional' and 'personal', after adding another nine, I’ve seen people writing the tel with two strokes:
9-9999-9999
. Remove the dash and save only the numbers.– Papa Charlie
expected format is that the user type the phone I validate if he type area code , or only phone or with the most accurate country code validate in regex also exactly as he said leaving the optional dash if he type or not more as I do this ?
– Pedro Amorim