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.

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.

Read Also:  File Upload - Auto Resize Compress-Reduce image using PHP

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 :

Read Also:  Simple website templates for beginners (with Examples)

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.