phone number validation in html form

Today, We want to share with you mobile number validation in php w3schools.In this post we will show you html phone number input, hear for 10 digit phone number validation in php we will give you demo and example for implement.In this post, we will learn about How To Allow Only 10 Digit Mobile Number Validation Using Javascript With Jquery with an example.

mobile number validation in html w3schools Code Example

Example 1:

The <input type="tel"> defines a somefield 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/Mobile number:</label>
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}">


Example 2: Mobile number validation pattern in PHP

preg_match('/^[0-9]{10}+$/', $mobile)

call it in a function:

function validate_mobile($mobile)
{
    return preg_match('/^[0-9]{10}+$/', $mobile);
}

I hope you get an idea about html code for phone number format.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.