Validation Identification document

  • consultoriahalcon
    Asked on June 6, 2017 at 6:16 AM

    Hello,

     

    I need to validate a field. The identification document. Is it possible to incluide Function script to validate this field??

    How should I incluide the function? o how could i do it?

     

    <script language="javascript"> 

    function validarFormatoDni(dni) {

    //alert('validando dni:' + dni + '...')

     

    if (dni!='')

    {

    //alert('dni no vacio')

    dni = dni.toUpperCase();

    //alert('despues de poner en mayusculas')

      numero = dni.substr(0,dni.length-1);

    //alert('despues de quedarme con el numero')

     let = dni.substr(dni.length-1,1);

    //alert('despues de quedarme con la letra')

      numero = numero % 23;

     letra='TRWAGMYFPDXBNJZSQVHLCKET';

      letra=letra.substring(numero,numero+1);

     if (letra!=let)

        return false;

        }

        return true;

    }

    }

    function validarDni(campo){

    if(campo.value!=""){

    if (!validarFormatoDni(campo.value)){

    alert("DNI/NIF incorrecto");

    campo.value="";

    campo.focus();

    }

    }

    }

    </script>

  • candy
    Replied on June 6, 2017 at 8:00 AM

    Hello,

    Unfortunately, we do not offer programming support.

    Also, it is not possible to inject JavaScript codes to a form. 

    Thank you.