Search code examples
javascriptvalidationqualtrics

Can I capture validation errors using javascript in a Qualtrics survey?


I have a Qualtrics survey that has six multiple choice questions on one page. I have set up custom validation for each question so that after the respondent clicks the next button, a message comes up if an incorrect answer was entered. I used the Qualtrics validation feature to do this.

My question is: How can I record the number of incorrect responses the first (and any subsequent times) the next button is clicked? Qualtrics does not offer an option for this, so I will need to use Javascript.


Solution

  • To count the number of times the next button is clicked on a page, create a next button counter embedded variable that you increment each time the next button is clicked in an onPageSubmit function.

    To count the number of incorrect responses, count the number of visible validation messages and save the count in an embedded variable in an addOnload function.