Skip to content
Recommend our themes and earn 30% of our share of every sale you bring. Free to join.Earn by recommending our themes Become an affiliate

Textfield only accept numeric values jQuery

Updated 19 Sep 2018

Source code

<script>
$(document).ready(function() {
	$("input").keydown(function(event) {
		if ( event.keyCode != 46 && event.keyCode != 8 && (event.keyCode < 48 && event.keyCode > 57 ) ) {
			event.preventDefault();
		}
	});
});
</script>

More code answers

Comments

Log in to leave a comment.