0
I’m developing a page with a login and password that searches the data in the company’s AD. I am using PHP and need to somehow allow only letters and dot (.) in the login field. I’m using the script below, it’s very basic but it works in parts. When I enter a number, it appears in the field, even using onkeypress or onkeyup. Is there any way for it to block even, nor appear in the field the invalid character?
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;
              }
        }
}
which means invalid character in this context?
– durtto
Numbers, accented letters and other symbols, except the point (.). Only this would be "valid" in the context of the page: digits="abcdefghijklmnopqrstuvwyxz."
– Diego
http://www.w3schools.com/jsref/event_onkeydown.asp onkeydown.
– Diego Souza