Is it possible to add a Custom Validation Message from the Library into javascript? | XM Community
Solved

Is it possible to add a Custom Validation Message from the Library into javascript?

  • 16 January 2020
  • 2 replies
  • 43 views

Userlevel 7
Badge +26
  • QPN Level 4 ●●●●
  • 216 replies
Hi,

I'm using some javascript from case nr 4 on this document that I found:
https://psrc.princeton.edu/sites/psrc/files/html_tips_tricks.pdf

But I wondered if it is possible to call up a custom validation message from the Message Library instead of a hardcoded error text.
So instead of:
var customErrorMessage = 'Write your message here';

to have some variable that uses a specific message from the Library.
Especially because Library messages support translation, I'm hoping that this way I can make my error message multilingual.
(And no, I can't just use the Custom Validation option instead of JavaScript because the Graphic Slider question type doesn't support Custom Validation)
icon

Best answer by ahmedA 6 January 2021, 00:02

View original

2 replies

Userlevel 4
Badge +9

We wanted to do the same thing, trying to use text from a message library in javascript in the header of a survey or theme. We asked Qualtrics support several years ago, and they said there was no way to retrieve message library items in javascript. Only embedded data fields, like this ${e://Field/varname}.
It would certainly be useful to be able to reference message library text, because of the translation capabilities. So far, looks like it's still not possible.

Userlevel 7
Badge +21

One workaround would be to place the required warning messages as question texts. Then you can use the method mentioned above. Your custom error message would be

"${q://QID128/QuestionText}"
. These questions could be hidden using the display logic set to false.
Ideally it should it work with translations (I haven't tested it) and just to be safe, ensure that these questions are somewhere in the survey, before the custom message is required.

Leave a Reply