Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Highlight other specify box in grid with js

Hi I have a 5point scale row oriented grid with Other specify option which is required only if rated as 4 or 5. I've added Custom JavaScript verification which displays an error message but doesn't highlight the other specify box.
if (SSI_GetValue('Q3f_r10') > 1 && SSI_GetValue('Q3f_r10_other') == '') {
    strErrorMessage = 'A response is required.';
}


Can someone help me with this?
related to an answer for: Make other specify optional in grid type
asked Mar 18 by ConstantineKlim (255 points)

1 Answer

+1 vote
I'd add this CSS to your grid question, defining whatever style rules we want to apply to the other specify when it is in an error state:

<style>
.my_error {
    border: 1px solid red;
}
</style>


Then I'd set the custom verification to run before system verification and add two lines like this:

$('.my_error').removeClass('my_error');
if (SSI_GetValue('Q3f_r10') > 1 && SSI_GetValue('Q3f_r10_other') == '') {
    strErrorMessage = 'A response is required.';
    $('#[% QuestionName() %]_r10_other').addClass('my_error');
}
answered Mar 18 by Zachary Platinum Sawtooth Software, Inc. (171,950 points)
Thanks Zachary!
...