Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/02/2009, 16:10
luks77
 
Fecha de Ingreso: diciembre-2007
Mensajes: 274
Antigüedad: 17 años, 3 meses
Puntos: 0
Respuesta: Agregar a todos los text

Hola adler. Muchas gracias por la ayuda.
Igual sigo teniendo problemas. Ahora no me pasa bien una variable a una funcion. Le quiero pasar la variable event.

Cita:
x=$(document)
x.ready(todoText)
function todoText()
{
$("input[type=text]").bind("keypress", function(){validar(event)})

}

function validar(e) { // 1
tecla = (document.all) ? e.keyCode : e.which; // 2
if (tecla==8) return true; // 3
patron =/[A-Za-z1-9\s]/; // 4
te = String.fromCharCode(tecla); // 5
return patron.test(te); // 6
}
No se cual podra ser la razon.La consola de errores me dice:"event is not defined" Pero no se como lo tengo que mandar.

Ahora si yo en un <input> pongo <input type="text" onkeypress="return validar(event)">
Ahi si me funciona.

¿Cual es mi error?
Desde ya muchas gracias....

Última edición por luks77; 07/02/2009 a las 16:18