 
			
				10/06/2010, 13:29
			
			
			     |  
      |    |    |    Fecha de Ingreso: abril-2010  
						Mensajes: 40
					  Antigüedad: 15 años, 6 meses Puntos: 0     |        |  
  |      Sumas con decimales        Buenas tardes compañeros, tengo el siguiente codigo que me hace la suma de de los textbox pero cuando quiero sumar con decimales por ej: 125.67 + 254.43 no me respeta los decimales y me da un valor entero, ¿como puedo hacer para que me de el resultado con decimales?   
gracias de antenamo   
saludos.     
<html> 
  <head> 
  <script>   
  function validarNumX(){ 
  entero = validarInt(document.miForm.num1.value); 
    if (entero==""){ 
      //document.miForm.num1.value="" 
      return "" 
    }else{ 
      res1=true 
      return entero 
    } 
  }   
  function validarNumY(){ 
  entero = validarInt(document.miForm.num2.value); 
    if (entero==""){ 
      //document.miForm.num2.value = ""       
      return "" 
    }else{ 
      res2=true 
      return entero 
    } 
  }   
  function validarInt(valor){ 
    valor = parseInt(valor) 
    if (isNaN(valor)) { 
      return "" 
    }else{ 
     return valor 
    }   
  }   
  function sumar(){ 
      if (validarNumX()=="" || validarNumY()==""){ 
        alert ("DEBE INGRESAR DATOS CORRECTOS") 
        document.miForm.suma.value = "" 
      }else{ 
        sol = validarNumX()+validarNumY() 
        document.miForm.suma.value = sol 
      }   
    }   
  </script>   
  </head> 
  <body>   
  <form name="miForm"> 
    <h3>Numero 1</h3><input name="num1" onBlur="validarNumX()" size =8><br><br> 
    <h3>Numero 2</h3><input maxlength="8" name="num2" onBlur="validarNumY()"><br><br> 
    <h3>Resultado</h3><input name="suma" size =8 onFocus = "sumar()">   
  </form>   
  </body> 
</html>           |