Require response for only one column in side by side question | XM Community
Skip to main content

I have a side by side question with 3 statements and 2 columns. I want to require response in a way that if respondents answer only to one of the two columns, it should be considered valid.
So in my sample here, if respondents say yes to column 1 to first item (row 1) it is valid response and they dont have to provide a response on column 2. In other words, one response for one row is required (not two).
How can I make that happen. Please help.
image.png

Hi Rajanigp ,
You should be able to do this with Custom Validation. Below is an example, built under the assumption that it is OK for respondents to answer both questions in a line.
image.png


Thank you Mathew. I tried the code and unfortunately it didn't work for me. I tired the following but I still get an error. Is there something I am missing. Also, the two statements within one logic (separated by OR) are identical and reference the row. Where are the different columns referenced?
image.png


The interface in Qualtrics leaves a lot to be desired. There's really no way to tell the columns apart, other than by eyeing them in order: in my example, Column 1 starts at the first occurrence of "Line 1 (Recode)", and Column 2 starts at the second occurrence, and so on. But after you select it and go back to the screen above, there's no way to tell them apart. You'll need to double-check that you have the right ones selected in each condition.
image.png


Thank you Mathew. I am going to try this out.


Hi MatthewM,
I tried the solution you have provided but I'm still getting an error. I have provided the screenshots below for your reference.
image.png
image.png


I think you have Force Response enabled for this question. You'll want to disable that if you're using Custom Validation.


Thank you Mathew. So, if I use this custom validation I will not be be able to fore a response? I have needed force response on this survey.
Will the validation work similar to asking respondents to answer a question?
Thank you again for your support.


The custom validation rules will essentially "force" the respondents to answer each line of the question. You can test this out by leaving a line blank and trying to move to the next page.


Hi MatthewM,
Yes it was the 'force response' that was adding the barrier, I don't know how did it slipped out of mind😅. Thank you so much!


Thank you! This works. So grateful!


UPDATE: I found the error!!! In the column options, under Text Entry Validation, Force Response was on!
Thank you again for the solution you provided above, the question are now requiring the needed responses. 

 

@MatthewM I am so thankful for this thread, I am using your solution but hitting a snag. I have a side by side question with one multiple choice and one open text per row. I have added the custom validation as shown above, but I still get an error that they need to complete the “Notes” column. I double checked that I didn’t have Force response turned on. Then I added custom validation that the “Notes” could be empty or not empty, hoping that would solve the issue. Do you have any suggestions on what might be the hang up? I have attached a screenshot.


@KathyM@MatthewM’s answer is great and should get you all the way.

However, if you are interested in JS based answer, please take a look at the code below. Just adding it here, as sometimes, when the rows grow, making edits becomes tedious.

 

Qualtrics.SurveyEngine.addOnReady(function () {
const quest = this;
const qc = quest.getQuestionContainer();

// Insert Fake Next Button
const nextButton = document.querySelector("#NextButton");
const fakeNextButton = nextButton.cloneNode(1);
nextButton.insertAdjacentElement("afterend", fakeNextButton);
nextButton.style.display = "none";

fakeNextButton.onclick = function () {
const allRows = Array.from(qc.querySelectorAll("tbody tr"));

// This section checks if there is an answer in each row
const isFilled = allRows.map((row) => {
// Check for single and multi select options
const hasSelected = !!row.querySelector(".q-checked");

// Check for text inputs
const hasText = Array.from(row.querySelectorAll(".InputText"))
.map((inputBox) => !!inputBox.value)
// Change .any to .all if you want to have all inputboxes filled
.any((inputBox) => !!inputBox);

// Change || to && if you want it to have both text and selects
return hasSelected || hasText;
});

// If yes, click the next button
if (isFilled.all((a) => a == true)) {
fakeNextButton.style.display = "none";
nextButton.style.display = "";
quest.clickNextButton();
}
// If not, highlight the row with the unanswered question.
else {
isFilled.forEach((a, index) => {
allRowslindex].style.border = "";
if (!a) {
allRowslindex].style.border = "2px solid red";
}
});
}
};
});

 


@ahmedA Thank you! I am in the process of learning to use JS, so this will be so helpful! I like that it highlights the row that was missed. I very much appreciate you sharing the code!


Hi ​@Rajanigp 

 

This is not the recommended approach. Since you are using radio buttons, it would be difficult for participant to uncheck response if clicked by mistake. Rather create simple matrix grid with 4 point scale and add headers for column 1 and 2 together, column 3 and 4 together using JS to give similar look-n-feel.

 

Thanks!


We can accomplish this by implementing custom validation for the question. Thank you.


Leave a Reply