Can not delete phone number in US National format when the input string has 3 characters
See original GitHub issueI’m using AsYouType to format the input phone number, I got an error when attempting to delete phone number by press Backspace when the input string has 3 characters.
Check out the gif and the code below:
new AsYouType('US').input(value)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Phone Number Formatting — How to Do It, Why It Is Important
You might think that choosing the right format, or ensuring that all customer phone numbers in your database are consistent is unimportant.
Read more >How do format a phone number as a String in Java?
I tried using DecimalFormat but that doesn't like the hyphen. Probably because it is meant for formatting decimal numbers and not longs. long...
Read more >E.164 phone number field configuration
How search works: Punctuation and capital letters are ignored. Special characters like underscores (_) are removed.
Read more >4.3. Validate International Phone Numbers - O'Reilly
^ # Assert position at the beginning of the string. \+ # Match a literal "+" character. (?: # Group but don't capture:...
Read more >Check whether second string can be formed from characters ...
It contains well written, well thought and well explained computer science and ... Input : str1 = geekforgeeks, str2 = geeks ... Output...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am was looking for an answer but don’t really like to start applying AsYouType after 3 digits… Here is what I came up with, hope it helps others:
This is kind of a helper function I use to include in input onchange if input type is phone
@nguyennb9 I was able to work around this by only formatting once the character count is over 3 digits. What I believe to be happening is that when you hit the backspace, the field is still evaluating to 3 digits which will add the parenthesis for US format. Adding in a conditional to start formatting after 3 digits have been entered worked well for me.