Table of Contents
In this post we are going to see HTML5 validation. Validation plays a major role in to securing a form in website. Now we learn about mobile number validation in HTML5 done by adding pattern attribute in the input field.
The on top of code validates a ten digit number. As seen within the code, it’s terribly easy no JavaScript or jQuery code is needed. The code is explained below.
- Input text field for getting into the number.
- Max length to limit the characters entered in just ten.
- Pattern attribute specifies the expression for checking the value of an input field. The pattern relies on the regular JavaScript expression. The square brackets ‘[ ]’ tells whether to validate text a-z or numbers 0-9 and flower bracket ” for telling the number of characters to enter.
- Required attribute is added if the number is mandatory.
- The title attribute is for describing the pattern of the users.