Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/02/2013, 12:09
emilkavg
 
Fecha de Ingreso: septiembre-2012
Ubicación: La Habana
Mensajes: 32
Antigüedad: 11 años, 7 meses
Puntos: 1
Respuesta: problemas con el foco en una funcion de decinales

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
  4. function Check()
  5. {
  6.    
  7.     checkdecimales('obj_ingresos')  
  8.     if(document.getElementById('obj_servicios').value.length > 0)
  9.     if(checkdecimales('obj_servicios')!= false)
  10.     if(document.getElementById('obj_ventas').value.length >0)
  11.     if(checkdecimales('obj_ventas')!= false)
  12.        alert("ok");
  13. }
  14. function checkdecimales(id) {
  15.     chk = /^([0-9]{1,27}\.[0-9]{2})$/
  16.     sFilter=document.getElementById(id).value;
  17.      if(!chk.test(sFilter))
  18.         {
  19.         msg  = "Debe entrar un entero con dos decimales separados por un (.).";
  20.         alert(msg);    
  21.         document.getElementById(id).value="";
  22.         document.getElementById(id).focus();
  23.         return false;
  24.         }
  25. }
  26. </head>
  27. <table width="25%" border="0" cellspacing="0" cellpadding="0">
  28.   <tr>
  29.     <td>Ingresos:
  30.       <input name="text" type="text" class="cajatexto" id="obj_ingresos" size="8" /></td>
  31.   </tr>
  32.   <tr>
  33.     <td>Servicios:
  34.     <input name="text2" type="text" class="cajatexto" id="obj_servicios" size="8"/></td>
  35.   </tr>
  36.   <tr>
  37.     <td>Ventas:
  38.     <input name="text3" type="text" class="cajatexto" id="obj_ventas" size="8" /></td>
  39.   </tr>
  40.     <tr>
  41.     <td>Ventas:
  42.     <input  type="button" onclick="Check()"/></td>
  43.   </tr>
  44. </body>
  45. </html>