I need to verify a form, and in this I have a field to enter phone numbers.
According to wikipedia the Argentine telephone numbers, I quote:
Area codes can be 2, 3, or 4 digits long, with the remaining 6, 7, or 8 digits being the local phone number.
For example, the number
+54 11 1234-5678
for Buenos Aires is made up of a 2-digit area code followed by an 8-digit telephone number; while it+54 341 123-4567
would be an example of a Rosario number.
In short, you would need a regular expression that covers all those cases. And I would need to add a rule to it, which would be that the +54
is optional.
At the moment I am using this expression as a last option:
/^\(?\d{2}\)?[\s\.-]?\d{4}[\s\.-]?\d{4}$/
but it's not what I'm looking for since this allows (11) 1234 3434
or 1123243434
, etc. I would need to add the rules explained above for example (353) 123 4345
and make +54
it optional