Foros del Web » Programando para Internet » Javascript »

problemas cuando incluyo onkeyup="" y onchange=""

Estas en el tema de problemas cuando incluyo onkeyup="" y onchange="" en el foro de Javascript en Foros del Web. Hola muy buenas, Tengo el problema en el navegador Chrome e IE, cuando incluyo onkeyup="return num_negativo(event,this);" ya que el onchange="alert();", no me funciona y no ...
  #1 (permalink)  
Antiguo 22/02/2014, 03:30
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 4 meses
Puntos: 4
problemas cuando incluyo onkeyup="" y onchange=""

Hola muy buenas,

Tengo el problema en el navegador Chrome e IE, cuando incluyo onkeyup="return num_negativo(event,this);" ya que el onchange="alert();", no me funciona y no se ejecuta.

En el firefox me funciona perfectamente, pero no en otros navegadores, porque?

Muchísimas gracias.

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<body>
<script type="text/javascript">
function num_negativo(e,element)
{
	
	var e;
	var element;
	var charCode 		= e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	
	if (element.value)
	{
		var cant = element.value;
	}
	
	if (cant > 0)
	{
		return document.getElementById(element.id).value = cant*2;
	}
	
	if ((charCode < 48 || charCode > 57) && charCode != 8 && charCode != 9 && charCode != 13 && charCode != 37 && charCode != 39  && charCode != 46)
	{
		return false;
	}
}
</script>
<form action="" method="post">
<input type="text" id="Equilibrio_2_C5" value="1" onkeyup="return num_negativo(event,this);" onchange="alert(1);" />
<input type="text" id="Equilibrio_2_C6" value="1" onkeyup="return num_negativo(event,this);" onchange="alert('2');" />
</form>
</body>
</html> 
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------

  #2 (permalink)  
Antiguo 22/02/2014, 05:17
Colaborador
 
Fecha de Ingreso: septiembre-2013
Ubicación: España
Mensajes: 3.648
Antigüedad: 10 años, 6 meses
Puntos: 578
Respuesta: problemas cuando incluyo onkeyup="" y onchange=""

Eso tiene que notificarse en la consola por narices

PD: En IE es window.event, no event.

Etiquetas: funcion, html, input, onkeyup
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:01.