A Validation Error resfreshes the page and JavaScript won't execute. Why? | XM Community
Skip to main content
I use this code in JavaScript to hide the PreviousButton on a page:



Qualtrics.SurveyEngine.addOnload(function() {

jQuery("input#PreviousButton.PreviousButton.Button").css("display", "none");

});



I use this code on the first question of the block, no page break, and put it in addOnload, addOnready, addOnunload.



However, one of the question has a validation parameter. When this validation is not met and the NextButton is pressed, the page reloads and the PreviousButton is back.



Why is that so and how to fix it?

I think your code is too complicated :)
Try this:
Qualtrics.SurveyEngine.addOnReady(function()
{
$('PreviousButton').hide();
});


https://www.qualtrics.com/community/discussion/comment/32605#Comment_32605You need to use

jQuery 
in place of
$ 
as
$ 
is a reserved token. Ref


I had a similar problem but fixed it (albeit in a hacky way) by putting the code inside a timer
See https://www.qualtrics.com/community/discussion/comment/37570#Comment_37570


Leave a Reply