Highlight error in large side-by-side where email address in incorrectly entered | XM Community
Skip to main content
Question

Highlight error in large side-by-side where email address in incorrectly entered


Forum|alt.badge.img+2
  • QPN Level 1 ●
  • 1 reply

Hi community.

I have a large side-by-side table with open ended text entry fields.  The open text entry must have correct email address format.  Not all fields will need text entry.  When an email address is incomplete or has the wrong format, I need to find a way to highlight the field, column or row to make it easier for the respondent to find their error.  This code is not working for me.  Any feedback or suggestions from the community would be greatly appreciated.

Qualtrics.SurveyEngine.addOnload(function()
{
    $(document).ready(function(){

$(".InputText").on("input",function(){

if ($(this).val() == "")
$(".InputText").css({backgroundColor:""});

else {
if (checkEmail($(this).val()))
$(".InputText").css({backgroundColor:""});
else
$(".InputText").css({backgroundColor:"red"});
}
})

function checkEmail(txt) {
var patt = /[a-zA-Z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,3}$/;
if(patt.test(txt))
return true;
else
return false;
}
})

});

 

 

 

3 replies

Forum|alt.badge.img
  • 1 reply
  • May 17, 2023

Fantastic information.  Thank you for sharing.

 


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • May 17, 2023

@EY_AL 

The below post should be helpful:

Need javascript code for highlighting unanswered row of matrix question | XM Community (qualtrics.com)

You can achieve the same view via Matrix type question.


Forum|alt.badge.img+2
  • Author
  • QPN Level 1 ●
  • 1 reply
  • June 7, 2023

Thanks Deepak. I’ll check this out.


Leave a Reply