Does the page reload if validation fails? | XM Community
Solved

Does the page reload if validation fails?


Badge

I'm working on a project in which participants are asked a question with multiple choice and text entry and I have a custom validation set up. I would like to use some javascript to track some information and was wondering if the page reloads every time an individual fails the validation or whether it just loads the first time you arrive at the page and that's all?

icon

Best answer by KS28 7 April 2020, 22:15

View original

16 replies

Userlevel 7
Badge +27

The page reloads when there is a validation error.

Badge

EDIT - spoke to Qualtrics customer support today and found out that the page does not reload

Userlevel 7
Badge +27

EDIT - spoke to Qualtrics customer support today and found out that the page does not reload

They gave you the wrong answer. Maybe they answered from a JFE virtualization perspective, but from a JavaScript perspective the page reloads and the addOnload and addOnReady functions are executed.

Badge

Oh wow interesting.. Good to know - thanks!

Userlevel 7
Badge +27


Userlevel 5
Badge +11

Is there a way to call an onload function from a button on a page via a bit of extra HTML code in a question? I ask this as I have an iframe with a PDF file in which sometimes it displays and sometimes it doesn't. I found that using a forced question helps to reload the pdf file but I'd rather find a nicer solution to reloading the pdf file
Thanks
Rod Pestell

Userlevel 7
Badge +27

Yes, see:
https://stackoverflow.com/a/11287072/4434072

Userlevel 5
Badge +11

Thanks TomG for the guidance - that was the bit I was missing! :)

Dear TomG,
I am trying to validate a SBS question by using custom validation. However, as you indicated above, the page reloads whenever the validation fails. This causes the JS codes to reload as well, and mess up the revealing sequence of the statements and columns.
May I ask whether you have any solution to work around this? Is it possible to still use custom validation while suppressing the reload?
image.png

Userlevel 7
Badge +27

You can't suppress the reload when using custom validation.
I'm not sure what your JS does, but if it were me, I would write it to gracefully recover when the page reloads.
Your other option would be to disable the Next button, do the validation with JS and enable the Next button when the validation criteria is met.

Thanks TomG! I shall create a new discussion for your first suggestion. Appreciate your advice please. Thank you.

Are we 100% sure validation reloads the whole page?
I'm very much a javascript noob but I also spoke to support and was also told that the entire page doesn't reload.
Also if the javascript functions executed again i don't think i'd have my own problem where css overrides javascript after a validation error ...

Userlevel 7
Badge +27

https://www.qualtrics.com/community/discussion/comment/37562#Comment_37562What you are seeing is probably a timing issue that you need to adjust for in your JS code.

Ah okay my bad. Wouldn't have thought timings would have been involved in something as simple as
Qualtrics.SurveyEngine.addOnload(function()
{
   var NextButton = document.getElementById("NextButton");
   NextButton.style.display = "block";
});
I shall brush up on my javascript! :)

Userlevel 7
Badge +27

Try changing addOnload to addOnReady.

I had previous tried it in both and had the same problem
Anyway thanks! because I thought about what you said about timings and wrote this which fixes (or papers over) the problem. Hacky as hell but works 🙂

image.png

Leave a Reply