( function( $ ){
$( document ).on( 'keypress', '.only-numbers', function( e ){
var charCode = ( e.which ) ? e.which : e.keyCode;
if( charCode > 31 && ( charCode < 48 || charCode > 57 ) ){
return false;
}
return true;
});
})( jQuery );
jQuery Accept only numbers on text field
Usage:
<input type="text" class="only-numbers" />
Usage:
<input type="text" class="only-numbers" />
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.