Giter Site home page Giter Site logo

jquery.rut.chileno's Introduction

jQuery Rut Chileno

Un simple y muy liviano (solo 1.07kb!) plugin para validar y formatear RUT Chilenos.

Requiere jQuery 1.6 o superior.

Ejemplo rápido

El modo más simple es agregando la función al input de texto que desees:

    $('.input_rut').rut();

Opciones

  • formatear : Da formato 12345678-5 en el evento BLUR (default: true)
  • on : Evento que ejecuta la verificación (default: 'blur')
  • required : Agrega/elimina la opción de hacer el input requerido (default: true)
  • placeholder : Agregar/eliminar el texto temporal del input (default: true)
  • error_html : Cambia el html cuando un Rut es inválido (default: '<span class="rut-error">Rut incorrecto</span>')
  • fn_error(input) : Función ejecutada al encontrar un error (default: mostrar error)
  • fn_validado(input) : Función ejecutada al validar el rut correctamente

Ejemplo cambiando opciones

    $('.input_rut').rut({
      fn_error : function(input){
        alert('El rut: ' + input.val() + ' es incorrecto');
      },
      placeholder: false
    });

Funciones

También puedes usar las funciones directamente

  • rut.validar(rut) : Retorna TRUE / FALSE dado un rut '12345678-5'
  • rut.dv(rut) : Retorna el digito verificador de un rut
  • rut.formatear(rut) : Retorna un string con el formato '12345678-5'
  • rut.quitar_formato(rut) : Elimina puntos y guion a un rut

Ejemplo:

var es_valido = $.rut.validar('12345678-5');

if(es_valido){
  alert('rut válido');
}

alert($.rut.quitar_formato('12.345.678-5'));
// Produce 123456785

jquery.rut.chileno's People

Contributors

kadumedia avatar luisepvs avatar

Stargazers

 avatar Rodrigo Benavente A. avatar Alexis Tapia Romero avatar Ing. Juan J. Gutierrez A. avatar Hernan Thiers avatar Erik Antillanca Pichún  avatar Cristopher Castro González avatar Rodrigo avatar Santiago Galvis avatar Mirko Balmaceda avatar Rodrigo Figueroa avatar

Watchers

James Cloos avatar  avatar Erik Antillanca Pichún  avatar

jquery.rut.chileno's Issues

Problemas con DV

Cuando se utiliza un Rut con dígito verificador "K" y este se pone en mayúscula, al momento de hacer el submit del formulario este envía el siguiente error: "Utiliza un formato que coincida con el solicitado".

P.D: Esta bkn el plugin, solo encontré ese error, saludos!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.