Es decir que solo ingrese: 1, 2, 250, pero no 1.5, 2.6
Por ahora tengo validado que no ingrese ni valores negativos, ni caracteres, ni superiores a 1000000
Aca el codigo de mi algoritmo:
Código HTML:
Ver original
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form name="datos">
<input type="text" name="lado" size="10" maxlength="7" />
<input type="text" name="valor" size="10" />
<input type="text" name="perimetro">
<br>
<br>
</form>
<br />
</body>
</html>
Y aca el codigo JavaScript donde valido (ubicando en el head):
Código Javascript:
Ver original
<script languaje="JavaScript">
function area()
{
lado=document.datos.lado.value;
valor=document.datos.valor.value;
apotema=document.datos.apotema.value;
lado = parseFloat(datos.lado.value, 10)
valor = parseFloat(datos.valor.value, 10) ;
apotema = parseFloat(datos.apotema.value, 10) ;
if ((document.datos.lado.value.length== "") || (document.datos.valor.value.length== "") || (document.datos.apotema.value.length== ""))
{
alert("EXISTEN VALORES NO INGRESADOS");
return false;
}
if ((document.datos.lado.value <= 0) || (document.datos.valor.value <= 0) || (document.datos.apotema.value <= 0))
{
alert("SOLO PUEDE INGRESAR VALORES POSITIVOS");
return false;
}
if ((document.datos.lado.value <= 0) || (document.datos.lado.value > 1000000))
{
alert("EL NUMERO DE LADOS DEL POLIGONO ES ENTRE 1 - 1 0 0 0 0 0 0");
return false;
}
if ( isNaN(lado) || isNaN(valor) || isNaN(apotema))
{
alert("TODOS LOS CAMPOS DEBEN SER VALORES NUMERICOS");
return false ;
}
perimetro=lado*valor;
document.datos.perimetro.value=perimetro;
document.datos.resultado.value=perimetro*apotema/2;
}
</script>
El algoritmo funciona y hace los calculos correctamente pero.......Como puedo hacer esa validación para que el usuario no me ingrese puntos decimales??
Agradezco me puedan colaborar
 
 


 Si consigo algo lo posteo, y si alguien sabe de algún código que lo postee también.
 Si consigo algo lo posteo, y si alguien sabe de algún código que lo postee también.

