Checkbox Text Entry Issue | XM Community
Skip to main content

Checkbox Text Entry Issue

  • December 5, 2022
  • 5 replies
  • 27 views

Forum|alt.badge.img

Hi all.
I have a checkbox question that has three choices with text entry. This question is regarding employee benefits. For the two selections 'paid vacation' and 'paid sick leave', I would like to let the respondents enter # of days with a telepad. For the 'other' option, I would like for them to have the typically keyboard.
The text entry boxes only appear if the answer is selected.

My code and question are below.

var QID= this.questionId;
   jQuery("#" + QID + " .InputText ").hide();
   jQuery("#" + QID + " input[type='checkbox']").each(function(){

      if(jQuery(this).prop("checked") == true)
      {
          var v1 = jQuery(this).attr("id");
        jQuery("[id*='"+v1+"~TEXT']").show();
        }
      else
      {
      var v1 = jQuery(this).attr("id");
      jQuery("[id*='"+v1+"~TEXT']").val('');
      jQuery("[id*='"+v1+"~TEXT']").hide();
     }    
   });


 jQuery("#" + QID + " .Selection ").on("click change",function(){

    jQuery("#" + QID + " input[type='checkbox']").each(function(){

      if(jQuery(this).prop("checked") == true)
      {
          var v1 = jQuery(this).attr("id");
        jQuery("[id*='"+v1+"~TEXT']").show();
        }
      else
      {
      var v1 = jQuery(this).attr("id");
      jQuery("[id*='"+v1+"~TEXT']").val('');
      jQuery("[id*='"+v1+"~TEXT']").hide();
     }    
   });
   });

});

Screenshot 2022-12-05 at 3.55.17 PM.png

5 replies

Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • December 5, 2022

https://community.qualtrics.com/XMcommunity/discussion/23235/checkbox-text-entry-issueHieJacobW
I am assuming that you need numerical values in the paid vacation & sick leave. Not sure if you have explored text entry validation. You can just click on the dropdown besides the choices for the numerical validation of that particular text entry. It would not allow respondents to move ahead if they enter a text in that particular text entry.
image.pngHope it helps!


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • December 5, 2022

Add this line after var QID:
jQuery("#"+QID+" .InputText").not(":last").attr("inputmode","numeric");


Forum|alt.badge.img
  • Author
  • December 6, 2022

Forum|alt.badge.img
  • Author
  • December 6, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/52884#Comment_52884Thanks for the help! I was particularly focused on the user interface rather than force responding a numerical value. I am trying to make this survey easy for mobile users, therefore, I want the telepad for numerical based answers.


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • December 6, 2022