Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save salipro4ever/6e72b2145563b8d72ead1a1c73e4e795 to your computer and use it in GitHub Desktop.
Save salipro4ever/6e72b2145563b8d72ead1a1c73e4e795 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);
}
@salipro4ever
Copy link
Author

VN cũ:

'phone' => ['required','regex:/^(01[2689]|0[93578])[0-9]{8}$/'],

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