Hi
I have a group with a long free text question and a multiple option with just one checkbox.
The user should check this button if the text question above is not relevant.
I'm trying to stop the user from going to the next page if they didn't enter any text AND they didn't check the checkbox.
Here's my javascript which I patched together from various other solutions suggested by TPartner.
My variable i always seems to return 0 even if I enter text in the field.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var qOpen = 3329;
var cb = 3487;
var i=0;
$('#question3329 input.text').change(function() {
if ($(this).val() != '') {
i=1;}
else {
i=0;}
});
// Interrupt next/submit
$('form#limesurvey').submit(function(){
if ($('#question'+cb+' input.checkbox:eq(0)').attr('checked') == false && i == 0) {
alert("Please enter either a comment or tick the checkbox");
return false;
} else {
return true;
}
});
});
</script>
Can anyone help?
Cheers
Paul