I'm using FireFox to test my script out. My goal is to allow white space, letters, backspace and tab to work, but for some reason i could break my code and type in a number which i don't want. How can i fix this issue? This is what i have so far. Please let me know how i could modify this code to make it work the way i want it to.
$(document).ready(function () {
$("#inputTextBox").keypress(function (event) {
var inputValue = event.which;
//Backspace ASCII = 8
//Tab ASCII = 9
if (!(inputValue >= 65 && inputValue <= 123)) {
if (inputValue === 8 && inputValue === 9){
event.preventDefault();
}
}
console.log(inputValue);
});
Aucun commentaire:
Enregistrer un commentaire