A much modern way to get phone number input from the user is to use the tel input type. You can implement the client-side form validation easily with HTML5 without using jQuery. Here we will show how you can integrate phone number validation with HTML5. To validate a phone number with a regular expression (regex), we will use type and pattern attribute in HTML input field. To validate a phone number with a regular expression (regex), we will use type and pattern attribute in HTML input field. The pattern trick article basically explains the exact opposite of what the "you don't need input type number" article says but is cited for something it does not say at all. But its not working , the field is taking all values and not just a 3 digit number. Java format string to phone number with dashes – (123) 456-6789 pattern Learn to format string to phone number pattern which is (123) 456-6789 . Maskjs. This conversion is generally required in applications where customer’s data has to be displayed and phone number is part of this data. Supports number, date, phone, currency, credit card, etc. html code for phone number format. maxlength.