Nil Pun
Nil Pun

Reputation: 17373

Javascript Telephone and mobile validation

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:

  1. Telephone, the first two digits should be one of ‘01’ ‘02’ ‘03’ ‘05’ ‘06’ ‘07’ ‘08’ ‘09’.

  2. Other phones such as ‘13xxxx’ or ‘1800xxxxxx’ is accepted and no restriction on length if number starts with 1.

  3. For Mobile, first 2 digits should start with '04' and length should be 10 digits.

Upvotes: 0

Views: 672

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

You can use a regular expression like

/^((0[12356789]\d+)|(1\d+)|(04\d{8}))$/;.test(value)

Demo: Fiddle

Upvotes: 1

Related Questions