0
When I click the input and hit Caps Lock, Backspace, it sends the patch message. for example, I type the normal and safe Backspace input to delete everything, when it comes at the end it shows the "fill only with letters" message. I used this code (name.match(/ [a-z" "A-Z_]+$/) but would like to release Capslock and Backspace.
//Reservation validation
const nameinput = document.getElementsByClassName('names');
const emailinput = document.querySelector('input[name="email"]');
const submitinput = document.querySelector('input[name="submitreservation"]');
console.log(nameinput);
Array.from(nameinput).forEach(function (item) {
item.addEventListener('keyup', function (e) {
var name = e.target.value;
if (name.match(/^[a-z" "A-Z_]+$/)) {
e.target.value = name.toUpperCase();
}
else {
console.log(e.target.value)
alert('Digite apenas letras !');
e.target.value ="";
}
})
})
I don’t quite get it, you wish there was no Capslock and Backspace message?
– Alvaro Guedes
That Alvaro. When I click on the input and Backspace grip if it is empty, msm thing with Caps appears the error. I do not want it. only with numbers and symbols
– Vitor Mendonça
the friend closed the post, but has nothing to do with my question
– Vitor Mendonça
i flagged the moderators pq your question is not duplicated and on validation with regex
– HudsonPH