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>
	<script src=""></script>		
		Mobile No. : <input type="text" maxlength="10" name="mobile_no" id="mobile_no">									
<script type="text/javascript">
$(document).ready(function () {
	$(document).on("input", "#mobile_no", function() {
		this.value = this.value.replace(/\D/g,'');

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 *