What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Validation Identification document

    Asked by consultoriahalcon on June 06, 2017 at 06: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>

  • Profile Image
    JotForm Support

    Answered by candy on June 06, 2017 at 08:00 AM

    Hello,

    Unfortunately, we do not offer programming support.

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

    Thank you.