Jquery Restrict only 10 numbers input in textbox

Today, We want to share with you Jquery Restrict only 10 numbers input in textbox.In this post we will show you the phone number should accept only 10 digit numbers in html5, hear for Restrict user to enter only 1) numbers, 2) 10 digits, 3) alphanumeric in TextBox by jquery we will give you demo and example for implement.In this post, we will learn about jQuery: Restrict “number”-only input for textboxes including decimal points with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Jquery Restrict only 10 numbers input in textbox

There are the Following The simple About JQuery – Allow only numeric values (numbers) in Textbox Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to restrict user to enter only numbers in textbox using jquery, so the how to restrict user to enter only numbers in textbox using javascript is used for this example is following below.

Allow only 10 numbers in textbox using Jquery

Example 1:

<!DOCTYPE html>
<html>
<head>
    <title>Allow only 10 numbers in textbox using Jquery - Mike McCarthy</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
   <h1>Logan Paul • Antonio Brown • Boxing • KSI • Barstool Sports</h1>
<form>
    <h1>Allow only 10 numbers in textbox using Jquery - Mike McCarthy</h1>
    <input type="text" name="mobile_cell" placeholder="Eneter Your Mobile..." pattern="[1-9]{1}[0-9]{9}">
  
    <button type="submit">Submit</button>
</form>
  
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<head>
    <title>Allow only 10 numbers in textbox using Jquery - Mike McCarthy</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body> 
    <h1>Logan Paul • Antonio Brown • Boxing • KSI • Barstool Sports</h1>
<form>
  <h1>Allow only 10 numbers in textbox using Jquery - Mike McCarthy</h1>
  <input type="text" name="mobile_cell" placeholder="Eneter Your Mobile..." maxlength="10" class="mobile_cell">
     
  <button type="submit">Submit</button>
</form>
    
</body>
    
<script type="text/javascript">
  $('.mobile_cell').keypress(function(e) {
      var mike_mccarthy = [];
      var jdk = e.which;
   
      for (i = 48; i < 58; i++)
          mike_mccarthy.push(i);
   
      if (!(mike_mccarthy.indexOf(jdk)>=0))
          e.preventDefault();
  });
</script>
</html>

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Text Box Validation(Number Only,10 Digit Mobile).
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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Simple Multiple Countdown timers using jquery
  2.   jQuery Ajax Calling Laravel Example From Scratch
  3.   How to allow only 10 digit number validation in Jquery?
  4.   JQuery Allow Only Numbers Input in Textbox
  5.   Convert object to Array in PHP Example
  6.   PHP Check if Multiple Array contains all Array
  7.   PHP change Laravel Date Formats Example
  8.   Download Remote File via PHP CURL
  9.   Eloquent Unions Query Laravel Database
  10.   What are OTP Frauds?

Leave a Reply

Your email address will not be published. Required fields are marked *