Clear Form / Page Function

This function can be called from any point in the survey to clear a form based on a validation
Add this to a script node somewhere in your survey
function ClearForm(form) {
  if(form.COMPOUND) //form with multiple items
  {
    var fcodes = form.domainValues(); //all precodes in form
    for(var i=0;i<fcodes.length;i++) //iterate through precode
      form[fcodes[i]].set(null); //clear item
  }
  else
    form.set(null);
}

On the validation i have based it on only one question to be answered on the page this will force the user to only pick one answer spread across a number of questions on the same page within the survey.

if(f(‘qnr_comprsheet_leftprimary‘).toBoolean() && f(‘qnr_comprsheet_rightprimary‘).toBoolean()) //both questions answered
{
   //Remove answers on both questions:
   ClearForm(f(‘qnr_comprsheet_leftprimary‘));
    ClearForm(f(‘qnr_comprsheet_rightprimary‘));
   //Provide error message
   RaiseError();
SetErrorMessage(2057,”Please select ONE primary option“);
}
If both questions are answered, clear the answers for both questions and display the error wording stated.
Change the parts in bold for your survey
Remember – 2057 is the language code – English united Kingdom