formsvalidationlimesurvey

Lime Survey Validate Text Field Equal to Other


I'm asking to the user for double email check, so I have two text fields and I need to know how to validate that the second text field input be equal to the first one.

Maybe somekind of regular expression in the validation field?

Thanks

UPDATE This basic script solved my need. Select "html source" on the Tiny editor of the second question, where you are asking again for the email and then add.

jQuery(document).ready(

function(){
  var first_email = jQuery("#answer496577X323X3572"),
  second_email = jQuery('#answer496577X323X3573');

  first_email.on('focusout', function(){
    email = first_email.val();

  });

  second_email.on('focusout', function(){
    email2 = second_email.val();
    if (email2 != email){
    alert("Mail input doesn't match");
    first_email.focus();
    }

  });

});

Change the "answer496577X323X3572" by the proper input ID of the fields.


Solution

  • Your system can be easily hijacked with deactivate the javascript. You don't validate via the server. And LimeSurvey can do both : show an error in javascript + validate in PHP (server).

    If you use a multiple text question with EMAIL for code, EMAIL for subcode #1 and CONFIRM for #2 : put this in "Question validation equation" advanced settings.

    EMAIL_EMAIL == EMAIL_CONFIRM.