jQuery

Number Validation for Textbox in jQuery

Spread the love

Add Number Validation for Textbox in jQuery –

It is Very easy task to validate in TextBox to accept numbers only in jQuery as given in bellow examples-

Example 1 : Numbers validation in jQuery “onkeypress” event by TextBox id to accept numbers only.

  • Add jquery.min.js library in header section of PHP file as showing in bellow code –
<!DOCTYPE html>
<html>
    <head>
	<script src="https://codeloveguru.com/master-library/js/jquery.min.js"></script>		
	</head>
	<body>	
		Mobile No. : <input type="text" maxlength="10" name="mobile_no" id="mobile_no">									
	</body>
</html>
<script type="text/javascript">
$(document).ready(function () {
	$(document).on("input", "#mobile_no", function() {
		this.value = this.value.replace(/\D/g,'');
	});	
});	
</script>

More jQuery Validation … Click here …

Number Validation for Textbox in jQuery

Leave a Reply

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