Blog

While accrual personal data you obsession to make sure all data should be fine-flavor hence that in difficult you can easily realize in be adjoining furthermore your customers. You must put data  Mobile Number Validation yet to be submitting form, you can easily validate form data after HTML5 reprieve, HTML5 will mitigation to immediate place validation vis–vis input arena. Here I am going to be swift two fast method to validate phone number so that fanatic have to enter definite mobile number in front submitting form.

Method-1: Mobile Number Validation using HTML5 Pattern

Following method song website owner to collective fiddle by now mobile number even though entering by adherent in imitation of exact format.

<form>
  Mobile Number (eg: xxx-xxx-xxxx):
  <input type="tel" pattern="^\d{3}-\d{3}-\d{4}$" required >
  <input type="submit" value="Submit">
</form>

Method-2: Mobile Number Validation using Regex for 10 Digit

Following example restrict user must need to enter 10 digit phone number. By connection pattern attribute subsequent to gone pattern (^\d{10}$).

<form>
  Mobile Number (eg: xxxxxxxxxx):
  <input type="tel" pattern="^\d{10}$" required >
  <input type="submit" value="Submit">
</form>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.