Last active
February 11, 2025 19:03
Revisions
-
donpandix revised this gist
Mar 9, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ 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]; -
donpandix created this gist
Dec 1, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ var Fn = { // Valida el rut con su cadena completa "XXXXXXXX-X" validaRut : function (rutCompleto) { if (!/^[0-9]+-[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');