Como forçar a entrada para permitir somente Alpha Letters?
usando jQuery aqui, no entanto incapaz de impedir que os números sejam digitados no campo de entrada
http://codepen.io/leongaban/pen/owbjg
Entrada
<input type="text" name="field" maxlength="8"
title="Only Letters"
value="Type Letters Only"
onkeydown="return alphaOnly(event);"
onblur="if (this.value == '') {this.value = 'Type Letters Only';}"
onfocus="if (this.value == 'Type Letters Only') {this.value = '';}"/>
jQuery
function alphaOnly(event) {
alert(event);
var key;
if (window.event) {
key = window.event.key;
} else if (e) {
key = e.which;
}
//var key = window.event.key || event.key;
alert(key.value);
return ((key >= 65 && key <= 90) || (key >= 95 && key <= 122));
}
Eu vi muitos exemplos aqui sobre como restringir a apenas números, e estou usando os códigos de chave corretos para a-z e A-Z. Você vê o que estou fazendo errado?