How can I modify the function keydown in javascript to not allow a decimal point? -


with can write numbers:

validahoranumero: function(iconttabla,icontfila){      var self = this;      $("#hora_"+iconttabla+"_"+icontfila+"_id").keydown(function (e) {          if ($.inarray(e.keycode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || $(this).val().indexof('.') != -1 || (e.keycode == 65 && ( e.ctrlkey === true || e.metakey === true ) ) || (e.keycode >= 35 && e.keycode <= 40)) {             return;         }         if ((e.shiftkey || (e.keycode < 48 || e.keycode > 57)) && (e.keycode < 96 || e.keycode > 105)) {             e.preventdefault();         }     }); }, 

i need modify method not allow write decimal point "."

how can this? thanks.

just remove 190, '.'

$("#field").keydown(function (e) {      if ($.inarray(e.keycode, [46, 8, 9, 27, 13, 110]) !== -1 ||     $(this).val().indexof('.') != -1 || (e.keycode == 65 && ( e.ctrlkey === true || e.metakey === true ) ) || (e.keycode >= 35 && e.keycode <= 40)) {         return;     }     if ((e.shiftkey || (e.keycode < 48 || e.keycode > 57)) && (e.keycode < 96 || e.keycode > 105)) {         e.preventdefault();     } }); 

https://jsfiddle.net/s3xqtdax/

you can check solution:

how allow numeric (0-9) in html inputbox using jquery?


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -