Ah, if you need to use the sum feature, several questions may not be appropriate.
Regarding the JavaScript...
For example, if you have a 4-option question where you want the minimums to be "5, 5, 20, 30" and the maximums to be "50, 50, 70, 100", you could:
1)
Set up your survey to use JavaScript
.
2) Insert something like this script in the question source. It will add a "max-min-error" class to any input that is out of its allowed max/min values and prevent the survey from advancing until the values are fixed.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// The variables
var minimums = [5, 5, 20, 30];
var maximums = [50, 50, 70, 100];
var errorAlert = 'One or more of the inputs is out of its allowed range. Please re-enter the values';
// Identify this question
var thisQuestion = $('#question{QID}');
// Add some attributes to the numeric inputs
$('input.text', thisQuestion).each(function(i) {
$(this).attr('data-min', minimums[i]);
$(this).attr('data-max', maximums[i]);
});
// Listeners on the numeric inputs
$('input.text', thisQuestion).bind('keyup change', function(event) {
if($(this).val() < Number($(this).attr('data-min')) || $(this).val() > Number($(this).attr('data-max'))) {
$(this).closest('li.question-item').addClass('max-min-error');
}
else {
$(this).closest('li.question-item').removeClass('max-min-error');
}
});
// Interrupt the Next/Submit function (to test for max/min errors)
$('#movenextbtn, #movesubmitbtn').bind('click', function () {
if($('li.max-min-error', thisQuestion).length > 0) {
alert(errorAlert);
return false;
}
});
});
</script>
3) Add something like this to the end of template.css:
Code:
.max-min-error input {
background: pink;
border: 1px solid red;
}