Hi there,
I found this old thread
with some JS on making only a few questions mandatory in a multiple short text question.
The select questions as mandatory is working but I am finding that the script is interfering with another question and quotas I have set up.
Q1 asks the level of interest a participant has in our research - Radio List - Yes / No / Someone Else.
Yes / Someone Else triggers Q2 which has the multiple short text question asking for further details.
If someone says No, then they are directed to the end of the survey via a Quota.
The JS for Q2 is somehow interfering with this Quota or Q1 as when I select No - and click next, the same pop up box regarding an answer needed appears. Even though Q2 is never presented to this person.
Could someone please let me know where my code is going wrong?
I tried changing #movenextbtn to #movesubmitbtn but then the code doesn't work at all.
I figure I need some identifying JS regarding 'if this question is presented' but am at a loss.
All help is greatly appreciated.
Here is also my exact code in the survey.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#movenextbtn').click(function(){
var needAnswer=false;
if ($("#answer448284X2875X55236fn").val()==""){
needAnswer=true;
$("#answer448284X2875X55236fn").css('background','red');
}
if ($("#answer448284X2875X55236sn").val()==""){
needAnswer=true;
$("#answer448284X2875X55236sn").css('background','red');
}
if ($("#answer448284X2875X55236org").val()==""){
needAnswer=true;
$("#answer448284X2875X55236org").css('background','red');
}
if ($("#answer448284X2875X55236ph").val()==""){
needAnswer=true;
$("#answer448284X2875X55236ph").css('background','red');
}
if ($("#answer448284X2875X55236em").val()==""){
needAnswer=true;
$("#answer448284X2875X55236em").css('background','red');
}
if (needAnswer){
alert ('Answer needed');
return false;
}else{
return true;
}
});
});
</script>