- Posts: 6
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
tpartner wrote: Since the inclusion of Expression Manager we need to have a space or line-break after all opening curly braces and before all closing curly braces. (don't get me started on the whole "valid JavaScript" discussion again)
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var q1ID = 68; var msg = 'Please specify in the comment box.'; // Hide the first 3 text inputs of Q1 $('#question'+q1ID+' li[id^="javatbd"]:eq(0) .comment').hide(); $('#question'+q1ID+' li[id^="javatbd"]:eq(1) .comment').hide(); $('#question'+q1ID+' li[id^="javatbd"]:eq(2) .comment').hide(); // Interrupt next/submit function $('#movenextbtn, #movesubmitbtn').click(function(){ // Reset some stuff var failedMandatory = 0; $('#question'+q1ID+' input.text').css({ 'background':'' }); // Loop through all check answers in Q1 $('#question'+q1ID+' input.checkbox:checked').each(function(i){ // Define the row var thisRow = $(this).parents('li:eq(0)'); // Check for empty mandatory text inputs if($('input.text:visible', thisRow).length > 0 && $('input.text', thisRow).val() == '') { $('input.text', thisRow).css({ 'background':'pink' }); failedMandatory = 1; } }); // Abort submit if any mandatory text inputs are empty if(failedMandatory == 1) { alert (msg); return false; } else { return true; } }); }); </script>