-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format on change #462
Comments
@bertrandflaujac FYI |
The plugin doesn't provide this out of the box, but it's easy to add: just add a "change" listener to the input, and in the handler, use the plugin's |
@jackocnr I think it would be a nice feature to have it with |
@sylfabre thanks for the offer, but I only want to add features when I know they will be useful to a lot of people, and there's just not the demand for this right now. |
@jackocnr Actually I think this is a bug: spaces are added when the plugin inits with |
It's nothing to do with |
@jackocnr Thank you for your clarification on the options. From what I understand of the code Have a look at this following use case about the re-formatting just after user has typed
=> The page displays data in two different formats : inconsistent behavior Or another use case :
=> Here a user action triggers a formatting In my opinion to get a consistent behavior:
I've checked on Microsoft Excel: if a cell is set to display 2 decimals and you type a number with 3 then on change event, the cell displays only 2 digits. The same applies with monetary format with $ or € symbol, or with the date format. But the formatting doesn't happen everywhere so we can agree to disagree on this matter 😄 |
Yeah find me a respectable website that auto-formats phone numbers on change, and I will reconsider ;) |
@jackocnr While updating my profile I've just seen that SNCF website does it. SNCF is the French national train company which makes €4 billion revenue a year and 12 millions unique visitors a month |
Haha looks like they're using intl-tel-input! Thanks for the reference - it's good to know. I will make note of this, and if it's something a lot of people want then I will consider adding it. |
For me the lack of this feature is the only reason why all the human kind don't use your plugin. You've made such a great work and then you've just not finished it !! |
@jackocnr I've noticed that Google Contact uses auto format too |
@sylfabre wow that is surprising! Well spotted. As far as I can tell this is a relatively new feature for Google Contacts and I want to see if it stands the test of time (and if they decide to use it on their other phone number inputs e.g. when you edit your Google account details, which doesn't currently auto format). You can read more about the original decision to remove the auto format feature here: #346 - the main issue is that at the time libphonenumber didn't directly support this functionality, and one of their maintainers explicitly advised us against using the library this way, but that was over 3 years ago - there is a chance that has changed now. |
It stands, buddy. Every web-site now autoformats a phone as you enter it. Add the feature, please :) |
I used inputMask, it works well. :)
|
Why this issue is closed ? Is there a solution for this issue ?? :( |
Sorry I don't want to add this feature as it's a massive can of worms and honestly I think it just creates confusion and doesn't add much value at all. I'm really surprised that Google do this on Google Contacts, but note that even here it is buggy/inconsistent e.g. if you start typing a US number "+17024" then it will auto add formatting chars as you type, so it appears "+1 702-4" and if you delete the 4, it will auto delete the hyphen, and then if you type 4 again it will auto add the hyphen again. BUT if you leave the 4 and go back and delete the hyphen, then delete the 4 after, so you're left with "+1 702" then when you try adding the 4 again, this time it doesn't auto add the hyphen. Inconsistencies like this just highlight how hard this problem is. HTML text inputs were just not designed for this kind of functionality. And whether you agree or disagree, what I can say for sure is that I don't have time to implement/maintain this kind of functionality. |
Steps to reproduce
Expected behaviour
The number should be formatted as 01 02 03 04 05
I get the correct formatting on https://rawgit.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/demo-compiled.html with
Actual behaviour
The number is formatted as 0102030405
Initialisation options
List any options you're using e.g. utilsScript or preferredCountries
The text was updated successfully, but these errors were encountered: