Skip to content

Instantly share code, notes, and snippets.

@tungvn
Last active January 16, 2024 07:45
Show Gist options
  • Save tungvn/2460c5ba947e5cbe6606c5e85249cf04 to your computer and use it in GitHub Desktop.
Save tungvn/2460c5ba947e5cbe6606c5e85249cf04 to your computer and use it in GitHub Desktop.
Vietnamese phone number Regex validation
/*
Before Septemper 15 2018, Vietnam has phone number start with 09*, 01(2|6|8|9).
After that, the phone number can start with 03, 05, 07 or 08.
So this function provide a way to validate the input number is a Vietnamese phone number
*/
function isVietnamesePhoneNumber(number) {
return /(03|05|07|08|09|01[2|6|8|9])+([0-9]{8})\b/.test(number);
}
@tyluudinh
Copy link

tyluudinh commented Oct 20, 2021

Updated: 20/10/2021
My regex:

const isValidPhone = phone => /^(0?)(3[2-9]|5[6|8|9]|7[0|6-9]|8[0-6|8|9]|9[0-4|6-9])[0-9]{7}$/.test(phone)

Updated: 13/09/2022

@quangld
Copy link

quangld commented Apr 12, 2022

const isValidPhone = phone => /(([03+[2-9]|05+[6|8|9]|07+[0|6|7|8|9]|08+[1-9]|09+[1-4|6-9]]){3})+[0-9]{7}\b/g.test(phone)

isValidPhone('783728642364287323437894534')
> true

@sanghavp
Copy link

Cảm ơn anh!

@XuanManh9999
Copy link

Thanks anh

@thinhfullstack
Copy link

Cảm ơn anh ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment