Reputation: 17373
I'm working on project where we need to validate Australian phone/mobile/1XXXX numbers.
Could someone please help me with validation of telephone number per below:
Telephone, the first two digits should be one of ‘01’ ‘02’ ‘03’ ‘05’ ‘06’ ‘07’ ‘08’ ‘09’.
Other phones such as ‘13xxxx’ or ‘1800xxxxxx’ is accepted and no restriction on length if number starts with 1.
For Mobile, first 2 digits should start with '04' and length should be 10 digits.
Upvotes: 0
Views: 672
Reputation: 388316
You can use a regular expression like
/^((0[12356789]\d+)|(1\d+)|(04\d{8}))$/;.test(value)
Demo: Fiddle
Upvotes: 1