Answers for "Javascript prevent user from being entering a negative value using the keyboard"

1

Javascript prevent user from being entering a negative value using the keyboard

var number = document.getElementById('number');

// Listen for input event on numInput.
number.onkeydown = function(e) {
    if(!((e.keyCode > 95 && e.keyCode < 106)
      || (e.keyCode > 47 && e.keyCode < 58) 
      || e.keyCode == 8)) {
        return false;
    }
}
Posted by: Guest on October-26-2021

Code answers related to "Javascript prevent user from being entering a negative value using the keyboard"

Code answers related to "Javascript"

Browse Popular Code Answers by Language