I have a javascript function that does not let you write numbers, only letters, in chrome it works exactly as it is proposed, now in mozilla it does not work, below my function:
function soletra(event) {
var value = String.fromCharCode(event.which);
var pattern = new RegExp(/^[a-záàâãéèêíïóôõöúçñ ]+$/i);
return pattern.test(value);
}
I made an adaptation to work, but it was not good that leaves some keys inactive if the field is in focus:
function soletra(event) {
if(event.keyCode == 9 || event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 39 ||event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 40)
return;
var value = String.fromCharCode(event.which);
var pattern = new RegExp(/^[a-záàâãéèêíïóôõöúçñ ]+$/i);
return pattern.test(value);
}
and the function call looks like this:
$("#id").bind("keypress paste drop", soletra);