Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/02/2014, 03:30
Avatar de syntex
syntex
 
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 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
------------------------------------------------