The second Text Box is Email that only allows email format.
The third Text Box is phone number, it only allows numbers.
You can use them to constrain input, apply formatting rules, and check lengths.
A regular expression can easily check whether a user entered something that looks like a valid phone number.
This code validates a 10 digit phone number taken in any format and sets the phone number text field to the desired output format.
If the number is valid then alert message will be displayed as ‘Phone number is valid’.
If the number is invalid, alert message will be displayed as ‘Phone number is not valid.
Regular expressions are patterns used to match character combinations in strings.
In Java Script, regular expressions are also objects.