Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/10/2010, 14:29
oscarbt
 
Fecha de Ingreso: abril-2009
Ubicación: Colombia
Mensajes: 949
Antigüedad: 16 años
Puntos: 27
Problema con validacion utilizando | | (or)

Tengo un formulario donde ingreso tres valores numericos y lo tengo validado para que no me ingrese valores negativos, iguales a cero o de tipo caracter

La validacion no me esta funcionando en todos los campos, ya he mirado y comparado con ejemplos de otros formularios que tengo pero no encuentro cual sera mi error

Agradezco me puedan colaborar y decirme cual es mi posible error

Aca el codigo html de ingreso de los valores:

Código HTML:
Ver original
  1. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  2. <title>Calculo</title>
  3. </head>
  4.  
  5.  
  6. <center>
  7.   <h1><b>CALCULO DE PERIMETRO DE UN TRIANGULO</b></h1>
  8. </center>
  9. <br />
  10. <hr />
  11. <form name="datos">
  12. <br><center><h3>VALOR LADO A </h3>
  13. <input  type="text" name="ladoa" id="ladoa" size="10" />&nbsp;&nbsp; &nbsp;&nbsp;
  14. <h3>VALOR LADO B </h3>
  15. <input  type="text" name="ladob" id="ladob" size="10"   />&nbsp;&nbsp; &nbsp;&nbsp;
  16. <h3>VALOR LADO C  EN RADICAL</h3>
  17. **&nbsp;
  18.    <img src="Imagenes/radical.gif" alt="signo radical" width="44" height="48">
  19. <input  type="text" name="ladoc" id="ladoc" size="10"  />&nbsp;&nbsp; &nbsp;&nbsp;
  20.  
  21. </center><br><br></td>
  22.     <td><br><center><h3>VALOR DE LA RAIZ CUADRADA </h3>
  23.  
  24. <input type="text" name="raiz">
  25. <h3>VALOR PERIMETRO </h3>
  26. <input type="text" name="perimetro" id="perimetro"></center><br>
  27.  
  28.  <center><input type="button" value="Calcular Perimetro" onClick="sumar()" >
  29.  
  30.  
  31. </body>
  32.  </html>

Y aca el codigo JavaScript donde ejecuto la funcion sumar() ubicada en el head

Código Javascript:
Ver original
  1. <script languaje="JavaScript">
  2.          function sumar()
  3. {
  4.     ladoa=parseFloat(document.getElementById('ladoa').value);  
  5. ladob=parseFloat(document.getElementById('ladob').value);
  6. ladoc=parseFloat(document.getElementById('ladoc').value);
  7.  
  8.  if ((document.datos.ladoa.value.length== "") || (document.datos.ladob.value.length== "") || (document.datos.ladoc.value.length== "")  )
  9.                
  10.                {
  11.         alert("EXISTEN VALORES NO INGRESADOS");
  12.         return false;
  13.        
  14.           }
  15.              if ((document.datos.ladoa.value <= 0) || (document.datos.ladob.value <= 0) || (document.datos.ladoc.value <= 0))
  16.                
  17.                {
  18.         alert("SOLO PUEDE INGRESAR VALORES POSITIVOS");
  19.         return false;
  20.        
  21.           }
  22.           if ( isNaN(ladoa) ||   isNaN(ladob) || isNaN(ladoc) )
  23.            {  
  24.         alert("TODOS LOS CAMPOS DEBEN SER VALORES NUMERICOS");
  25.                
  26.         return false  ;
  27.  
  28.         }
  29.  
  30. ladoc=document.datos.raiz.value= Math.sqrt(ladoc); 
  31. perimetro=ladoa + ladob + ladoc ;
  32. document.getElementById('perimetro').value=perimetro;  
  33. }
  34.  
  35.       </script>

Donde tengo mi error??..
Agradezco la colaboracion