I am developing a page with a login and password that searches the data in the company's AD. I'm using PHP and I need to somehow only allow letters and period (.) In the login field. I'm using the script below, it's pretty basic but it works in parts. When I type a number, it appears in the field, even using onkeypress or onkeyup. Is there any way to block it even, nor does the invalid character appear in the field?
function somente_letras(campo){
var digits="abcdefghijklmnopqrstuvwyxz.";
var campo_temp;
for (var i=0;i<campo.value.length;i++){
campo_temp=campo.value.substring(i,i+1);
if (digits.indexOf(campo_temp)==-1){
campo.value = campo.value.substring(0,i);
return false;
}
}
}