Skip to content Skip to sidebar Skip to footer

Is It Possible To Disable 'step' In Input Type Number

I would like to know if its possible to override the browser step behaviour or to intercept and change the step value before steping or prevent stepping from happening as a functio

Solution 1:

Not sure if this is what you're looking for but I'll give it a try.

WebKit desktop browsers add little up down arrows to number inputs called spinners. You can turn them off visually like this:

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin:0;
}

Source: https://css-tricks.com/snippets/css/turn-off-number-input-spinners/

EDIT

Solved it! Here is the fiddle

http://jsfiddle.net/649d66bb/

  $(document).ready(function() {
    $("input[type=number]").on("focus", function() {
        $(this).on("keydown", function(event) {
            if (event.keyCode === 38 || event.keyCode === 40) {
                event.preventDefault();
            }
        });
    });

});

Post a Comment for "Is It Possible To Disable 'step' In Input Type Number"