mobile number validation in html w3schools Examples

html phone number input

The input type=”tel” defines a field for entering a telephone number. Note: Browsers that do not support “tel” fall back to being a standard “text” input. Tip: Always add the label tag for best accessibility practices!

The <input type="tel"> defines a field for entering a telephone number. Note: Browsers that do not support "tel" fall back to being a standard "text" input. Tip: Always add the <label> tag for best accessibility practices!

Define a field for entering a telephone number:

<label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}">

how to validate mobile number in html form?

<div>
  <label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone"  pattern="+94[7-9]{2}-[0-9]{3}-[0-9]{4}" value="+94">
 </div>

Source: infinityknow.com