Foros del Web » Programando para Internet » Javascript »

Problema con validación incompatible entre navegadores

Estas en el tema de Problema con validación incompatible entre navegadores en el foro de Javascript en Foros del Web. Buenas a todos, tengo un algoritmo para calcular el area de un triangulo, lo valido con JavaScript, la validación funciona perfectamente en google Chrome y ...
  #1 (permalink)  
Antiguo 08/10/2010, 14:29
 
Fecha de Ingreso: abril-2009
Ubicación: Colombia
Mensajes: 949
Antigüedad: 15 años
Puntos: 27
Problema con validación incompatible entre navegadores

Buenas a todos, tengo un algoritmo para calcular el area de un triangulo, lo valido con JavaScript, la validación funciona perfectamente en google Chrome y Mozilla Firefox, pero en Internet Explorer no muestra los mensajes de alert de validacion ni tampoco me ejecuta la función...
Existe algun código JavaScript o tal vez HTML para que el script de js me funcione en todos los navegadores?



Aca el codigo:
Lo prueban tal como esta en Google Chrome y luego en Internet Explorer y noten la diferencia

Código HTML:
Ver original
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>Cuadrado</title>
  5.  
  6.      
  7.      <script languaje="JavaScript">
  8.     function sumar()
  9.     {
  10.         document.forms['datos'].elements['ladoa'];
  11.         document.forms['datos'].elements['ladob'];
  12.        document.forms['datos'].elements['ladoc'];
  13.  
  14.         if ((ladoa.value == "") || (ladob.value == "") || (ladoc.value == "")  )
  15.         {
  16.             alert("EXISTEN VALORES NO INGRESADOS");
  17.             return false;
  18.         }
  19.         var fladoa = parseFloat(ladoa.value);
  20.         var fladob = parseFloat(ladob.value);
  21.         var fladoc = parseFloat(ladoc.value);
  22.         if ( isNaN(fladoa) ||   isNaN(fladob) || isNaN(fladoc) )
  23.         {  
  24.             alert("TODOS LOS CAMPOS DEBEN SER VALORES NUMERICOS");
  25.             return false;
  26.         }
  27.         if ((fladoa <= 0) || (fladob <= 0) || (fladoc <= 0))
  28.        {
  29.            alert("SOLO PUEDE INGRESAR VALORES POSITIVOS");
  30.            return false;
  31.        }
  32. a=document.forms['datos'].elements['raiza'].value = Math.sqrt(fladoa);
  33.  b=document.forms['datos'].elements['raizb'].value = Math.sqrt(fladob);
  34.    c=document.forms['datos'].elements['raizc'].value = Math.sqrt(fladoc);
  35.        var perimetro=a + b + c;
  36.        document.getElementById('perimetro').value=perimetro;  
  37.    }
  38. </script>
  39.  
  40.  
  41. </style>       
  42. </head>
  43.  
  44. <body>
  45.  
  46. <center><h1><b>CALCULO DE PERIMETRO DE UN TRIANGULO</b></h1>
  47. </center>
  48. <br />
  49. <hr />
  50. <form name="datos">
  51.  
  52.  
  53.     <td><br><center><h3>VALOR LADO A EN RADICAL</h3>
  54.    
  55.    
  56. <input  type="text" name="ladoa" id="ladoa" size="10"  />
  57.  
  58. <h3>VALOR LADO B EN RADICAL </h3>
  59.    
  60.  
  61. <input  type="text" name="ladob" id="ladob" size="10"  />&
  62.  
  63. <h3>VALOR LADO C EN RADICAL</h3>
  64.  
  65.  
  66. <input  type="text" name="ladob" id="ladoc" size="10"  />
  67.  
  68. <h1>RESULTADOS:</h1>
  69.  
  70.    <td><br><center><h3>VALOR DE LA RAIZ CUADRADA LADO A </h3>
  71.  
  72. <input type="text" name="raiza" disabled="disabled">
  73. <h3>VALOR DE LA RAIZ CUADRADA LADO B</h3>
  74.  
  75. <input type="text" name="raizb" disabled="disabled">
  76. <h3>VALOR DE LA RAIZ CUADRADA LADO C </h3>
  77.  
  78. <input type="text" name="raizc" disabled="disabled">
  79.  
  80. <h3>VALOR PERIMETRO </h3>
  81. <input type="text" name="perimetro" id="perimetro" disabled="disabled"></center><br></td>
  82.  
  83.  
  84.   <h3>
  85.    <center><input type="button" value="Calcular Perimetro" onClick="sumar()" > <input name="Limpiar"  type="reset" id="Limpiar" value="Borrar valores ingresados "> </center>
  86. </h3>
  87. </form>
  88. <br />
  89.  
  90. </body>
  91. </html>

Agradezco me puedan colaborar
  #2 (permalink)  
Antiguo 08/10/2010, 14:32
Avatar de _cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 10 meses
Puntos: 310
Respuesta: Problema con validación incompatible entre navegadores

Cambia document.forms['datos'].elements['ladoa']; por ladoa=document.forms['datos'].elements['ladoa']; , y así sucesivamente.
Saludos (:
__________________
" Getting older’s not been on my plans
but it’s never late, it’s never late enough for me to stay. "
Cigarettes - Russian Red
  #3 (permalink)  
Antiguo 08/10/2010, 15:30
 
Fecha de Ingreso: abril-2009
Ubicación: Colombia
Mensajes: 949
Antigüedad: 15 años
Puntos: 27
Respuesta: Problema con validación incompatible entre navegadores

Lo he probado de esa forma pero me ingresa a la validacion:

Código Javascript:
Ver original
  1. if ( isNaN(fladoa) || isNaN(fladob) || isNaN(fladoc) )
  2. {alert("TODOS LOS CAMPOS DEBEN SER VALORES NUMERICOS");
  3.  return false;
  4.  }

Etiquetas: incompatible, navegadores, validar
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 01:22.