Position of error message on page | XM Community
Skip to main content

Hello, I have a custom coded error message that appears if a participant's response is not correct. My code, based on other forum responses works perfectly. However, the error message gets inserted below the next button at the bottom of the page. I want to move the error message to closer to the question (above the Next button). Is there a way to modify my code to be able to do that? Current code below..

if (res == correct) {
  jQuery('#NextButton').click();
  jQuery('#CustomNextButton').hide();
} else {

  /* This is where you set your error message text */
  var errorMsg = "Please enter the correct code";
  var x = document.createElement("DIV");
  var t = document.createTextNode(errorMsg);
  x.className = "custom-warning";
  x.appendChild(t);
  document.getElementById('Questions').parentElement.appendChild(x);
jQuery('.custom-warning').css("background", "pink");
jQuery('.custom-warning').css("color", "red");
jQuery('.custom-warning').css("font-size", "12px");


}
});

Remove ".parentElement" from this line:
document.getElementById('Questions').parentElement.appendChild(x);


Awesome! thanks so much! perfectly placed now.


Leave a Reply