Want create site? Find Free WordPress Themes and plugins.

In this article I will show how to use JQuery to allow only numbers in textbox or allow only numeric characters in textbox using JQuery. In below code user can enter only numeric values in textbox.

Script:

$(document).ready(function() {
	$("#my_text_box").keydown(function(event) {
		// Allow only backspace and delete
		if ( event.keyCode == 46 || event.keyCode == 8 ) {
			// let it happen, don't do anything
		}
		else {
			// Ensure that it is a number and stop the keypress
			if (event.keyCode < 48 || event.keyCode > 57 ) {
				event.preventDefault();	
			}	
		}
	});
});

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.

Did you find apk for android? You can find new Free Android Games and apps.

Posted by Abhay Kumar

I am Abhay Kumar from New Delhi (India). I'm working as a Web Developer from last 3+ years. You can follow me on Twitter, Facebook or Google+.