Add a dash to an automatic full phone number

Question:

Can I automatically add a dash "-" to autocomplete?

Let's say I have a phone number field, and if someone dials their phone number, it will display the autostart of the browser.

Ex.

This is the browser autocomplete value 1234567890

As soon as they choose that I want to automatically format it to

123-456-7890

Since the site has a site that does not have a validation format in its telephone field, you can enter a 10-digit number, and if you have this in your browser’s cache, it will also be displayed in another telephone field.

Thanks in advance.

+5
source share
1 answer
$('#phone-number-field').keyup(function(){ $(this).val($(this).val().replace(/(\d{3})\-?(\d{3})\-?(\d{4})/,'$1-$2-$3')) }); 
+14
source

All Articles