Checking if error message is displayed or not | XM Community
Solved

Checking if error message is displayed or not

  • 27 September 2018
  • 2 replies
  • 13 views

Userlevel 1
Hi all,
I have a delayed question appearing after a timeout. Participants need to answer it correctly, if not qualtrics validates with the inbuilt validation. The challenge: on failed validation, the page reloads, executing the onload jquery code again --> The delayed question is delayed again. Instead it should condition the delay to be executed only the first time the page loads: my approach: if the error msg is not shown, set delay = 0.

I tried checking the css property of the ValidationError like so
`if ( jQuery(".ValidationError").css("display") == "none" ) { ... }`
but this doesn't work.

How to check if the validation failed?
Thanks,
Jana
icon

Best answer by TomG 27 September 2018, 17:11

View original

2 replies

Userlevel 7
Badge +27
Try this:
```
if(jQuery("#"+this.questionId+" .ValidationError").is(":hidden")) { ... }
```
Userlevel 1
Hi Tom,
thank you for the quick response. Unfortunately that doesn't to the trick: Adding it within `addOnReady`, it fires even when the validation error is going to be displayed.

EDIT
Adding it also to `addOnload` it worked. Thank you!

Leave a Reply