In this tutorial, We will learn how to allow only 10 numbers in textbox using jquery. We allow only 10 digit number validation in jquery.
Example:
<!DOCTYPE html>
<html>
<head>
<title>How to allow only 10 digit number validation in Jquery?</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<form>
<label>Moblie No</label>
<input type="text" name="moblie_no" class="moblie-no" placeholder="Enter numbers">
<button type="submit">Submit</button>
</form>
</body>
<script type="text/javascript">
$("input[name=moblie_no]").attr("maxlength", "10");
</script>
</html>
Output:
Thanks, May this example will help you.