Hello Qualtrics Community,
I am working on thinking through a future research project where one text response question asks participants to write a very personal response, and then afterward participants respond to several quantitative questions about their response. Due to ethical reasons, I don't actually want to record the information participants type in the text box, but I do want to make sure they take the time to answer the question. I am not sure what is possible, but I am hoping for some guidance on how I either can immediately delete participants response to that specific question only upon submitting their survey, OR how I can record perhaps the number of words or characters participants type without seeing their actual response.
Thanks in advance!
We can create a text area or input text box using HTML code and on click of next button capture the number of words in an embedded data or in hidden qualtrics text input box.
nmordini - Use the below code in JS for the required question, it will remove the text which is entered by the respondent and they can move to next question. Make sure the question is optional and if you want to force the respondent to enter the text then you can add custom validation using JS but default force response option of Qualtrics will not allow to move ahead.
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
var textAns = jQuery(".InputText").val()
if(textAns.length > 0)
{
jQuery(".InputText").val('')
}
}
});
Agreed with SurajK answer. Also, if you want to capture the number of characters entered by the respondent, then you can use below updated code:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
var textAns = jQuery(".InputText").val().trim();
if(textAns.length > 0)
{
Qualtrics.SurveyEngine.setEmbeddedData("TextLength", textAns.length);
jQuery(".InputText").val('')
}
}
});
Make sure you have added "TextLength" embedded data as the first element in survey flow.
rondev SurajK Thank you both very much! Would you also be able to show me how to force response in the code as well? I do not have much coding experience.
https://www.qualtrics.com/community/discussion/comment/27194#Comment_27194You can just check the force response option for this question.
https://www.qualtrics.com/community/discussion/comment/27194#Comment_27194You will have to take care of this using fakebutton, add the fakebutton using the below code,
In the fakebutton click function add the below code,
var qid = this.questionId;
var textval = jQuery("div[id='"+qid+"']").find(".InputText").val()
if(textval.length == 0)
{
jQuery("div[id='QR~"+qid+"~VALIDATION']").css("display","block");
jQuery("div[id='QR~"+qid+"~VALIDATION']").html('');
jQuery("div[id='QR~"+qid+"~VALIDATION']").append("Please answer this question.");
}
else
{
jQuery("#NextButton").click()
}
SurajK
Thank you again for your help. I am probably doing something wrong, but I am unable to get the forced response section to work. Can you explain where this goes within the fakebutton code?
var qid = this.questionId;
var textval = jQuery("div[id='"+qid+"']").find(".InputText").val()
if(textval.length == 0)
{
jQuery("div[id='QR~"+qid+"~VALIDATION']").css("display","block");
jQuery("div[id='QR~"+qid+"~VALIDATION']").html('');
jQuery("div[id='QR~"+qid+"~VALIDATION']").append("Please answer this question.");
}
else
{
jQuery("#NextButton").click()
}
https://www.qualtrics.com/community/discussion/comment/27264#Comment_27264Yes, use the below code in JS,
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
jQuery("#NextButton").hide();
jQuery("#Buttons").append("")
var qid = this.questionId;
jQuery('#FakeNextButton').click(function(){
var textval = jQuery("div[id='"+qid+"']").find(".InputText").val()
if(textval.length == 0)
{
jQuery("div[id='QR~"+qid+"~VALIDATION']").css("display","block");
jQuery("div[id='QR~"+qid+"~VALIDATION']").html('');
jQuery("div[id='QR~"+qid+"~VALIDATION']").append("Please answer this question");
}
else
{
jQuery("#NextButton").click()
jQuery('#FakeNextButton').hide()
}
});
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.