简体   繁体   中英

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.

You can use a regular expression like

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

Demo: Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM