Hello!
I need help with validation in my survey.
I use the "question by question mode" to show the survey
In one of the questions I have a multiple short free text and I need to validate some subquestions like email, phone number (only numbers), etc.. I found this code in the forum
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
var emailExp = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
// Interrupt the submit function
$('form#limesurvey').submit(function () {
// Override the built-in "disable navigation buttons" feature
$('#moveprevbtn, #movenextbtn, #movesubmitbtn').attr('disabled', '');
var email = $("#answer31822X121X22232");
var flag = emailExp.test(email.val());
if (flag || email == '') {
return true;
} else {
alert ('The email is invalid!');
return false;
}
});
});
</script>
The validation works great but the navigation buttons still inactive and I can´t move to the next question even the email field is correct.
The next question is...
I have a question with "multiple choice with comments" and "other option" so the question is "select only the items you have" and the subquestions are pencil, pen, eraser.
In the commet box of each subquestion the imput is only numbers (number of pencils, pens, erasers have). In other option can put other object and the total you have.
I need to sum all the numbers entered in the selected choices to get a total of 100 and validate when the total isn't 100.
Thanks and sorry for my bad english... is not my language