verify Chilean rut (identity card) javascript

I leave here the code to verify the Chilean identity card (javascript)

anyone know of tutorials or courses in Spanish ?? 


I found it at https://cesarg.cl/




var Fn = {

    // Valida el rut con su cadena completa "XXXXXXXX-X"

    validaRut : function (rutCompleto) {

        if (!/^[0-9]+[-|-]{1}[0-9kK]{1}$/.test( rutCompleto ))

            return false;

        var tmp     = rutCompleto.split('-');

        var digv    = tmp[1]; 

        var rut     = tmp[0];

        if ( digv == 'K' ) digv = 'k' ;

        return (Fn.dv(rut) == digv );

    },

    dv : function(T){

        var M=0,S=1;

        for(;T;T=Math.floor(T/10))

            S=(S+T%10*(9-M++%6))%11;

        return S?S-1:'k';

    }

}



// Uso de la función

alert( Fn.validaRut('11111111-1') ? 'Valido' : 'inválido');

Hi Hector,

I don't quite understand the goal of your post. What exactly is your OutSystems-related question?

Kilian Hekhuis wrote:

Hi Hector,

I don't quite understand the goal of your post. What exactly is your OutSystems-related question?

 
Maybe I did not do it the right way, my intention is to contribute since this is used a lot in Chile

Excuse my pessim english I support myself in the google translator 

 

Ok, I understand, thanks :). I moved the post to the "Hints and how-to guides" forum.