DEV Community

SEO - NT Tech Innovation
SEO - NT Tech Innovation

Posted on

Validating Bangladeshi Mobile Numbers for bKash and Nagad Checkout (Regex + JS)

If you build checkout forms for Bangladeshi users, you'll hit this fast. People type their bKash or Nagad number in five different ways.

01712345678. +8801712345678. 8801712345678. 017-1234-5678. Even ০১৭১২৩৪৫৬৭৮ in Bangla digits.

Your form should accept all of them and store one clean format.

The rules

Bangladeshi mobile numbers are 11 digits starting with 01, followed by an operator digit from 3 to 9. With the country code it becomes 880 plus the last 10 digits.

Step 1: convert Bangla digits

const BN = '০১২৩৪৫৬৭৮৯';

function toLatinDigits(str) {
  return str.replace(/[০-৯]/g, d => BN.indexOf(d));
}
Enter fullscreen mode Exit fullscreen mode

Step 2: strip noise and normalize

function normalizeBdMobile(input) {
  let n = toLatinDigits(String(input)).replace(/[\s\-()]/g, '');
  n = n.replace(/^\+/, '');
  if (n.startsWith('880')) n = '0' + n.slice(3);
  return /^01[3-9]\d{8}$/.test(n) ? n : null;
}

normalizeBdMobile('+880 1712-345678'); // "01712345678"
normalizeBdMobile('০১৭১২৩৪৫৬৭৮'); // "01712345678"
normalizeBdMobile('01212345678');      // null (invalid operator)
Enter fullscreen mode Exit fullscreen mode

Step 3: show a friendly error

Don't just say "invalid". Tell people what you expect.

const msg = 'Enter an 11-digit number like 017XXXXXXXX';
Enter fullscreen mode Exit fullscreen mode

Small touch. Big drop in support messages.

Why this matters for small shops

A lot of Bangladeshi online businesses take payment only through mobile wallets. Social media service panels, small fashion pages, digital product sellers. If the number field rejects a real customer, that's a lost sale. Simple as that.

For example, panels like SMM Booster BD rely on wallet payments, so a forgiving number field directly affects how many orders go through.

Recap

  • Convert Bangla digits first.
  • Strip spaces, dashes and the plus sign.
  • Map 880 to 0.
  • Validate with /^01[3-9]\d{8}$/.
  • Store one format everywhere.

Written by MD Fozla Rabbi, SEO Specialist.

Top comments (1)

Collapse
 
packetexchange_dev profile image
Packet Exchange •

Converting the Bangla digits first is the bit most people forget, nice touch.

One small addition from carrier land: some folks type +880 01712345678, keeping the zero after the country code, so trimming that extra zero saves a few more real customers.

Regex can't tell you a number is live, which is why we built verification at Packet Exchange, happy to have you kick the tyres.

Do you store the 01 format or the 880 one?