How to do an input mask for HTML5 telephone input and regex pattern

HandiworkNYC.com picture HandiworkNYC.com · May 31, 2013 · Viewed 20.2k times · Source

I would like to have a telephone input that automatically inserts two dashes into the phone number, and as the user types, the numbers automatically go before and after the dashes appropriately like:

555 - 555 - 5555

Is this possible using the html5 telephone input and pattern attribute? Is there a cross browser way to do so?

Thanks!

Answer