When I\'m giving input type number the letter e and special charecters are also displaying in input field. I want to display only digits. How to block them?
e
If you want + sign in your phone number field then you can use this code.
var inputBox = document.getElementById("inputBox"); var invalidChars = [ "-", "e", ]; inputBox.addEventListener("keydown", function(e) { if (invalidChars.includes(e.key)) { e.preventDefault(); } });