RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.39k stars 2.17k forks source link

Country Code - handle if exists and when it doesn't #2365

Open mathewrmullan opened 4 years ago

mathewrmullan commented 4 years ago

More of a question - is it possible to set the mask for a phone number and handle whether the country code exists and when it doesn't?

When the auto-fill option is used in the browser, the phone can be brought in with the lead "1" for the country code. If the input mask is set to "(999) 999-9999" then the first digit within the parentheses is the country code (1) and the last digit of the phone number is cut off.

Is there a way to set the input mask so that it handles the country code if it exists (i.e. "1 (555) 123-4567") and ignore it altogether if it doesn't (i.e."(555) 123-4567")?

RobinHerbots commented 4 years ago

@mathewrmullan ,

Something like

Inputmask("[1 ](999) 999-9999").mask("test2");