Cleave.js – Format input text content when you are typing
I've tried similar libraries and they all suffer the same general "I don't know what the backspace key just did" sorta issues...Just look at the top features listed on their Github:* CC number - doesn't actually support all PAN formats - 19 digits exist although extraordinary rare. NEVER try to do anything fancy with your CC details field because if people try to pay you and can't you've lost a customer.* Phone number formatting - doesn't support all phone # formats. Leave this as flat text (non-numeric) or numeric for base telephone # and a text field for extension.* Date formatting - use type="date" so you get native mobile support for date entry.* Numeral formatting - use type="number" so you get native mobile support for numeric entry.