A Validation Error resfreshes the page and JavaScript won't execute. Why? | XM Community
Solved

A Validation Error resfreshes the page and JavaScript won't execute. Why?

  • 31 July 2019
  • 3 replies
  • 52 views

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?
icon

Best answer by JosephK 21 May 2021, 16:44

View original

3 replies

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

Userlevel 7
Badge +21

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