Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/03/2006, 13:44
cesar16
 
Fecha de Ingreso: marzo-2004
Mensajes: 81
Antigüedad: 20 años, 1 mes
Puntos: 0
Validacion caracteres y Enter

Hola, tengo un codigo que valida un campo de texto. Lo hace bien pero si presiono enter no lo valida.
¿Como puedo añadirle ese evento?

Código HTML:
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú. 1234567890?¿,-@€$";
  var checkStr = formulario.texto.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	  if (ch == checkOK.charAt(j))
		break;
	if (j == checkOK.length)
	{
	  allValid = false;
	  break;
	}
  }
  if (!allValid)
  {
	 alert('Caracteres inválidos en el campo \"Texto\".');
	 formulario.texto.focus();
	 return false;
  }