Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/08/2014, 08:11
gmyb
 
Fecha de Ingreso: junio-2011
Ubicación: uruguay
Mensajes: 42
Antigüedad: 15 años, 4 meses
Puntos: 0
validación de documento

hola, estoy validando un documento pero no logro que me muestre si es valido o no.
El codigo javascript está correcto, el problema creo que está en como lo asocio con mi input....


Código PHP:
<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin título</title>

<
head>
<
script type="text/javascript">
function 
ValidateDocument(source, args) { 
var 
cedula = args.Value; if (isNaN(cedula) || parseInt(cedula) != cedula) { 
//La cedula no es un numero
args.IsValid = false; return; 
alert("La cedula no es un numero");
} 
var 
multiplicador = [4, 3, 6, 7, 8, 9, 2 ]; 
var 
cd = cedula % 10;
 var 
i = 0; 
var 
calc_cd = 0; 
while (
cedula > 0 && i < 7) {
cedula = Math.floor(cedula / 10); 
calc_cd += cedula % 10 * multiplicador[i++];
} 
calc_cd = (calc_cd % 10 == 0) ? 0 : 10 - (calc_cd % 10);
if (
calc_cd == cd) { 
args.IsValid = true;
 } 
else
 { 
args.IsValid = false; 
}
}
</script>
</head>
<body>
<form name="cedula">
<input type="text" id="cedula" onchange="ValidateDocument(source, args)">
</form>
</body>
</html> 
alguna idea? gracias!!