Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> function Check()
{
checkdecimales('obj_ingresos')
if(document.getElementById('obj_servicios').value.length > 0)
if(checkdecimales('obj_servicios')!= false)
if(document.getElementById('obj_ventas').value.length >0)
if(checkdecimales('obj_ventas')!= false)
alert("ok");
}
function checkdecimales(id) {
chk = /^([0-9]{1,27}\.[0-9]{2})$/
sFilter=document.getElementById(id).value;
if(!chk.test(sFilter))
{
msg = "Debe entrar un entero con dos decimales separados por un (.).";
alert(msg);
document.getElementById(id).value="";
document.getElementById(id).focus();
return false;
}
}
<table width="25%" border="0" cellspacing="0" cellpadding="0"> <input name="text" type="text" class="cajatexto" id="obj_ingresos" size="8" /></td> <input name="text2" type="text" class="cajatexto" id="obj_servicios" size="8"/></td> <input name="text3" type="text" class="cajatexto" id="obj_ventas" size="8" /></td> <input type="button" onclick="Check()"/></td>