Answers for "how to prevent e in input type number"

1

prevent user from typing e,+,- from number input

var inputBox = document.getElementById("inputBox");

var invalidChars = [
  "-",
  "+",
  "e",
];

inputBox.addEventListener("keydown", function(e) {
  if (invalidChars.includes(e.key)) {
    e.preventDefault();
  }
});
Posted by: Guest on November-18-2020
0

javascript how to get rid of e with number input

document.querySelector(".your_class").addEventListener("keypress", function (evt) {
    if (evt.which != 8 && evt.which != 0 && evt.which < 48 || evt.which > 57)
    {
        evt.preventDefault();
    }
});

// 0 for null values
// 8 for backspace 
// 48-57 for 0-9 numbers
Posted by: Guest on December-05-2019
0

prevent user from typing e,+,- from number input

<input type="number" id="inputBox" />
Posted by: Guest on November-18-2020

Code answers related to "how to prevent e in input type number"

Browse Popular Code Answers by Language