Other Textboxes within grid questions do not force a response within the textbox in the row header. This JavaScript will disable and uncheck the row's answer options unless text has been input in the Other Textbox field.
Check it out in an example survey!
OR
Add a survey with this setup to your account!
This workaround uses the following features:
Setup
- Start by setting up a Radio Button Grid or Checkbox Grid on a page in your survey, with any number of other rows included.
- Add a JavaScript action to the same page, and paste in the following code.
var otherRows = function (type) {
var tableClass = 'sg-type-table-' + type;
var inputs = $('.' + tableClass + ' :text[name*="-other"]').parents('tr').find(':' + type);
inputs.prop('disabled', true)
inputs.parents('tr').find(':text').on('keyup blur', function () {
var rowPlacement = $('.' + tableClass + ' tr').index($(this).parents('tr'));
if($(this).val() && $(this).val() != '') {
$('.' + tableClass + ' tr:nth-child(' + rowPlacement + ') :' + type).prop('disabled', false);
$('.' + tableClass + ' tr:nth-child(' + rowPlacement + ') :' + type).removeAttr('disabled');
} else {
$('.' + tableClass + ' tr:nth-child(' + rowPlacement + ') :' + type).prop('disabled', true);
$('.' + tableClass + ' tr:nth-child(' + rowPlacement + ') :' + type).prop('checked', false);
}
});
}
$(otherRows('radio'));
$(otherRows('checkbox'));
Now, record a few test responses and make sure your validation works as it should!
Scripting and Other Custom Solutions
We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.
If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your needs. Beyond this, check out our Professional Services; these folks have the scripting chops to help you to achieve what you are looking for!
Admin
— Dave Domagalski on 10/03/2019
@Heather: Thank you for your question!
The script should continue to work with multiple radio/checkbox grid questions on the same page. I have just tested this and can confirm that it does.
If you continue to run into trouble with this, please don't hesitate to reach out to our Support team and they can take a closer look:
https://help.surveygizmo.com/help/surveygizmo-support-hours
Best regards,
David
Technical Writer
SurveyGizmo Learning & Development
— Heather on 10/03/2019
Hi there,
I have 3 Radio Button Grids on the same page, that this only seems to work for the first one. Can it/should it work for more than one Radio Button Grid on the same page?
thank you!
Heather
Admin
— Dave Domagalski on 06/05/2019
@Azure: Thank you for your note!
My apologies for the trouble. This script is intended only to ensure that text is input into the 'other' textboxes before the associated checkboxes/radio buttons can be selected.
When a grid question is required, all rows in that grid must be answered, including any 'other' rows.
It sounds like you are looking to dynamically require an answer to an 'other' row only if some text has been input into the 'other' box of that row. I'm afraid that this example script has not been written to accommodate this specific scenario.
While we do not have any readily available scripts for this specific request, our Support team may be able to offer some suggestions based on your specific use-case.
Please don't hesitate to reach out to us:
https://help.surveygizmo.com/help/surveygizmo-support-hours
Best regards,
David
Technical Writer
SurveyGizmo Customer Experience
— Azure on 06/05/2019
Hello, I tried this, but if you make the question required this JavaScript doesn't work as it is supposed to. What we are trying to achieve is to have a radio buttons / check boxes grid question where we have several options and 2 additional fields where customers can add more options. We want the system to require responses for the existing options and then require responses only if respondents have entered additional options. If they have left the entry fields empty, we want that they can go on to the next question. Would you please advise how we could do that?
Admin
— Dave Domagalski on 05/07/2019
@Sarah: Thank you for your note!
I took a look at the sample script and tested this in my account. It appears to be working for both Radio Button and Checkbox Grid questions.
This is something that our Support team can take a closer look into to make sure there is not something specific to your survey that might be causing the issue.
Please don't hesitate to reach out!
https://help.surveygizmo.com/help/surveygizmo-support-hours
David
Technical Writer
SurveyGizmo Customer Experience
— Sarah on 05/07/2019
This isn't working on radio button grid questions again--only with those set up as check boxes. Please fix.
Admin
— Dave Domagalski on 08/09/2018
@Steve: Thank you for your note!
The script has been updated to function properly with both question types.
Thank you for letting us know!
David
Documentation Specialist
SurveyGizmo Customer Experience
— Steve on 08/08/2018
It seems that this no longer works on radio button grids, only checkbox grids.