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<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<center>
<h1><b>CALCULO DE PERIMETRO DE UN TRIANGULO
</b></h1> </center>
<br><center><h3>VALOR LADO A
</h3> <input type="text" name="ladoa" id="ladoa" size="10" /> <input type="text" name="ladob" id="ladob" size="10" /> <h3>VALOR LADO C EN RADICAL
</h3> **
<img src="Imagenes/radical.gif" alt="signo radical" width="44" height="48"> <input type="text" name="ladoc" id="ladoc" size="10" />
<td><br><center><h3>VALOR DE LA RAIZ CUADRADA
</h3>
<input type="text" name="raiz"> <h3>VALOR PERIMETRO
</h3> <input type="text" name="perimetro" id="perimetro"></center><br>
<center><input type="button" value="Calcular Perimetro" onClick="sumar()" >
Y aca el codigo JavaScript donde ejecuto la funcion sumar() ubicada en el head
Código Javascript
:
Ver original<script languaje="JavaScript">
function sumar()
{
ladoa=parseFloat(document.getElementById('ladoa').value);
ladob=parseFloat(document.getElementById('ladob').value);
ladoc=parseFloat(document.getElementById('ladoc').value);
if ((document.datos.ladoa.value.length== "") || (document.datos.ladob.value.length== "") || (document.datos.ladoc.value.length== "") )
{
alert("EXISTEN VALORES NO INGRESADOS");
return false;
}
if ((document.datos.ladoa.value <= 0) || (document.datos.ladob.value <= 0) || (document.datos.ladoc.value <= 0))
{
alert("SOLO PUEDE INGRESAR VALORES POSITIVOS");
return false;
}
if ( isNaN(ladoa) || isNaN(ladob) || isNaN(ladoc) )
{
alert("TODOS LOS CAMPOS DEBEN SER VALORES NUMERICOS");
return false ;
}
ladoc=document.datos.raiz.value= Math.sqrt(ladoc);
perimetro=ladoa + ladob + ladoc ;
document.getElementById('perimetro').value=perimetro;
}
</script>
Donde tengo mi error??..
Agradezco la colaboracion