Hi,
sorry for the late answer, the example I brought was a too simplistic. I thought there might be a way that I can use a script for all questions/question types to fire JavaScript when the question validation tip is not met. Because this would make it easier to apply nearly the same code to style different questions, when question validation is not met.
But since this doesn’t seem to be realistic, thanks for the tip with the listener. I tried that out and it works:
My original problem was – I did not say it – that some respondents showed me that they did not check a secondary answer option when the secondary answer options pop up. They just do not see the secondary answer options popping up. Since the secondary answer options need approx. 0.6 sec to pop up, some respondents were already mentally at the next question (I think this delay is because of JavaScript combined with question validation). Because of this behavior of the respondents I styled the secondary answer options when none of these are checked. As far as I could investigate, adding a red border to the checkboxes of the unanswered secondary answer options is complicated, because the checkbox cannot be styled easily, so I just styled the text. Anyway, this is the code I used to highlight unanswered secondary answer options:
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function() {
$('body').on('change', '.secondary-item input:checkbox', function(i) {
if($(this).is(':checked')) {
$('.secondary-item').find('label.checkbox-label.control-label').css({
'border-bottom': 'initial',
'background-color' : 'initial'
});
}
else {
$('.secondary-item').find('label.checkbox-label.control-label').css({
'border-bottom': '1px solid red',
'background-color' : '#ffeeee'
});
}
});
});
</script>
secondary answer option is chosen.
secondary answer option is not chosen.