DÃgito Verificador
Publicado por DANIEL (5 intervenciones) el 07/12/2020 02:08:05
Hola, tengo problema con el digito verificador, como implementarlo. Lo que necesito es que en una form escribo escribo el rut y que me vaya mostrando el dÃgito a medida que escribo o cuando pierda el foco..
Mi código es:
Mi código es:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
if (!empty($_POST)){
$rut = $_POST['rut'];
$rut_dv = $_POST['rut_dv'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<script>
function dv($rut){
$s=1;
for($m=0;$rut!=0;$r/=10)
$s=($s+$rut%10*(9-$m++%6))%11;
echo, chr($s?$s+47:75);
}
</script>
</head>
<body>
<form action="" method="POST">
<input type="text" name="rut" id="rut" value="<?php echo (!empty($rut)) ? $rut : ""; ?>">
<input type="text" name="rut_dv" id="rut_dv" >
</form>
</body>
Valora esta pregunta
0