Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

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 Ban

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));
}

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)

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';

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.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.