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

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

  • July 31, 2019
  • 3 replies
  • 80 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?

Best answer by JosephK

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

3 replies

JacquelineS

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


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • December 11, 2020

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

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


  • Answer
  • May 21, 2021

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