AsYouType doesn't work for "FR" and other countries. Only works for "US".
//AsYouType doesn't work for "FR" and other countries. Only works for "US". // please fix it asap let format = new AsYouType("FR").input(e.target.value);
having same issue for Singapore numbers
new AsYouType('SG').input('80901234')
it has issue when the number input starts with '809' for some reason
Perhaps that's Google's issue. See https://github.com/catamphetamine/libphonenumber-js?tab=readme-ov-file#bug-reporting
It's crazy, having same issue here, can you help reach out. @catamphetamine
Also, is there a quick alternative we can use?
Hi @iamsamiadnan,
I looked into this and here’s what I found.
-
Singapore (from the comment): As of current metadata, it formats correctly.
new AsYouType('SG').input('80901234') // → "8090 1234" ✅You can also verify this on the demo page (it uses “max” metadata).
-
France (from the issue description): AsYouType doesn’t add digits. If a user types without the national trunk prefix
0, formatting won’t engage:new AsYouType('FR').input('612345678') // → "612345678" // no formatting (missing 0) new AsYouType('FR').input('0612345678') // → "06 12 34 56 78" ✅If you want a proper national render after input (regardless of whether
0was typed), get the final number and format it:const f = new AsYouType('FR') f.input(e.target.value) const formatted = f.getNumber()?.formatNational() // e.g. "06 12 34 56 78"
Also, ensure you’re on the latest version/metadata so you get the most recent formatting behavior.
Refs:
- Demo (shows SG 80901234 → “8090 1234”): https://catamphetamine.gitlab.io/libphonenumber-js/?parseCountry=US&parseValue=213-373-4253&asYouTypeCountry=SG&asYouTypeValue=80901234&findNumbers