<input type="text" name="country_code" title="Error Message" pattern="[1-9]{1}[0-9]{9}"> 

This will ensure

  1. It is numeric
  2. It will be max of 10 chars
  3. First digit is not zero
Answer from Vinay Lodha on Stack Overflow
🌐
W3Resource
w3resource.com › javascript › form › phone-no-validation.php
JavaScript: HTML Form - Phone Number validation
At first we validate a phone number of 10 digit. For example 1234567890, 0999990011, 8888855555 etc. ... <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript form validation - checking non-empty</title> <link ...
🌐
AbstractAPI
abstractapi.com › api guides, tips & tricks › 5 ways to implement 10-digit phone number validation in html
5 Ways to Implement 10-Digit Phone Number Validation in HTML
1 month ago - First, sign up at Abstract API and copy the Phone Validation API key from your dashboard. Store the key as an environment variable, for example "ABSTRACT_PHONE_KEY", in your build system or secrets manager.
🌐
CodeHim
codehim.com › home › text & input › 10 digit phone number validation in html
10 Digit Phone Number Validation in HTML — CodeHim
January 22, 2024 - Add the following script tag just ... const userPhoneNum = document.getElementById("userPhoneNum"); const content = document.getElementById("content"); const content__phoneNumber = document.getElementById("content__phoneNumber"); // regex variable ...
🌐
AbstractAPI
abstractapi.com › api guides, tips & tricks › 10 digit phone number validation
10-Digit Phone Number Validation: Best Practices & Tools - Abstract
July 24, 2025 - Validating phone numbers is a crucial step in ensuring data accuracy and user experience. This guide has covered: The structure of U.S. 10-digit phone numbers. Maximum length constraints for validation. Common mistakes and how to avoid them. Excel-based validation techniques. Standardized phone number formatting. Technical implementation using JavaScript, Python, and HTML5...
🌐
Talkerscode
talkerscode.com › howto › 10-digit-phone-number-validation-in-html.php
10 Digit Phone Number Validation In HTML
July 1, 2023 - <!DOCTYPE html> <html> <head> <title> ... enter your enter your mobile number </label> <input type="tel" name="phone" id="phone" placeholder="0123456789" pattern="[0-9]{10}"> <br><br> <label for=""> please enter your telephone ...
🌐
W3Schools
w3schools.in › javascript › validate-a-phone-number
JavaScript Phone Number Validation - W3Schools
<script> // Validate phone number function function validatePhoneNumber() { // Get and trim phone number input const phoneNumber = document.getElementById('phoneNumber').value.trim(); // Regex pattern for 10-digit phone number const pattern = /^\d{10}$/; // Validate phone number and update ...
🌐
Medium
medium.com › @techsolutionstuff › 10-digit-phone-number-validation-in-jquery-891bbed1c3a6
10 Digit Phone Number Validation in jQuery | Medium
October 8, 2024 - We’ll also see how to validate phone numbers in PHP using patterns. ... The Regex validation gives users the flexibility to enter numbers in different formats according to their requirements. <html> <head> <title>10 ...
Find elsewhere
🌐
Medium
medium.com › @sachin.kumarr9904 › how-to-check-and-validate-phone-number-input-in-html-and-javascript-f72212bf980d
How to Check and Validate Phone Number Input in HTML and JavaScript | by Sachin Kumarr | Medium
September 14, 2023 - <label for=”phone”>Phone Number:</label> <input type=”tel” id=”phone” name=”phone” pattern=”[0–9]{10}” required> Here, we’ve added the pattern attribute with a regular expression to ensure that only 10-digit numbers are ...
🌐
RegExr
regexr.com › 3aa8n
10 digit phone no
Validate patterns with suites of Tests.
🌐
CodeWithRandom
codewithrandom.com › 2023 › 02 › 18 › 10-digit-phone-number-validation-javascriptjquery-phone-number-validation-html-css-jquery
10 Digit Phone/Mobile Number Validation In JavaScript
February 27, 2023 - In this blog, We learn how to Validate a 10 Digit Phone/Mobile Number Using Html, Css, and JavaScript (jquery) Code. So let's start with a basic HTML Structure for the 10 Digit Phone/Mobile Number Validation.
🌐
CodexWorld
codexworld.com › home › how to guides › phone number validation with html5
Phone Number Validation with HTML5 - CodexWorld
August 18, 2017 - To validate a phone number with a regular expression (regex), we will use type and pattern attribute in HTML input field. The following example code validates a phone number and checks whether the user provided a phone number in the correct ...
🌐
Digittrix Infotech
digittrix.com › scripts › email-and-phone-number-validation-in-html-and-javascript
Email and Phone Number Validation in HTML and JavaScript
June 17, 2025 - <script> const form = document.getElementById('contactForm'); const email = document.getElementById('email'); const phone = document.getElementById('phone'); const emailError = document.getElementById('emailError'); const phoneError = document.getElementById('phoneError'); form.addEventListener('submit', function(e) { e.preventDefault(); emailError.textContent = ''; phoneError.textContent = ''; const emailPattern = /^[^ ]+@[^ ]+\.[a-z]{2,}$/i; const phonePattern = /^\+?\d{10,14}$/; let valid = true; if (!emailPattern.test(email.value)) { emailError.textContent = 'Invalid email format.'; valid
🌐
Squash
squash.io › how-to-match-standard-10-digit-phone-number-with-regex
How To Match Standard 10 Digit Phone Numbers With Regex
September 1, 2023 - These patterns or functions are ... For example, in JavaScript, you can use the pattern attribute with the value "[0-9]{10}" in an HTML input element to enforce a 10-digit phone number....
🌐
Sololearn
sololearn.com › en › Discuss › 2284410 › how-to-make-input-of-number-only-takes-10-digit-eg-mobile-number
How to make input of number only takes 10 digit. Eg mobile number | Sololearn: Learn to code for FREE!
It is very easy set maxlength to 10 digits like this <Input type="tel" name="tel" maxlength ="10" > 10th May 2020, 6:51 AM · 𝖆𝖊𝖙𝖍𝖊𝖗 · Answer · Learn more efficiently, for free: Introduction to Python · 7.1M learners · ...
🌐
Tech Solution Stuff
techsolutionstuff.com › post › how-to-validate-10-digit-mobile-number-using-regular-expression
How To Validate 10 Digit Mobile Number Using Regular Expression
March 30, 2024 - When we are working with form validation at that time you need to restrict user to enter invalid value and users allow only numeric value or valid number. So let's see regular expression for 10 digit mobile number ... <html> <head> <title>How To Validate 10 Digit Mobile Number Using Regular ...