Text box with text masked to user | XM Community
Solved

Text box with text masked to user

  • 26 February 2019
  • 2 replies
  • 60 views

Badge +3
I'm trying to create a textbox entry field and would like the text on the screen to be masked (with ** or ---- for example), but to have the actual text typed by the respondent recorded. If possible, it would be great to be able to have the respondent type this info, see the * but also have a way to toggle to "show" them the text prior to hitting submit or moving to the next question.

Is this possible, and if so, can anyone supply the accompanying code?
icon

Best answer by smdebb 27 February 2019, 20:28

View original

2 replies

Hello @smdebb ,

Here is the basic code for this:
Paste the below code in the TextEntry question type js(OnReady)

var that=this.questionId;
jQuery("#"+this.questionId+" .InputText").attr("type","password");
var button="<input type='button' id='bid' value='show' / >";
jQuery(button).insertAfter(".InputText");
jQuery("#bid").on('click',function(){
if(jQuery(this).val()=="show"){jQuery(this).val("hide");jQuery("#"+that+" .InputText").attr("type","text");}
else{jQuery(this).val("show");jQuery("#"+that+" .InputText").attr("type","password");}
});
Badge +3
Thanks for your help @Shashi! If I can inquire further.... I added the JS to the survey item, which is an open ended question (text box response). There is a toggle button for show/hide, but it doesn't seem to toggle between shown vs. hidden text. I am not even a novice in JS so I can't speak to what is wrong.

Thanks!

Leave a Reply