How to reset and disable textbox when the checkbox is checked | XM Community

How to reset and disable textbox when the checkbox is checked

  • 4 November 2022
  • 4 replies
  • 341 views

Badge +2

Hi Community,
I'm trying to work with reset the value and disable textbox when the checkbox is checked. I tried to do it but what I only work is disable the textbox. How to add the reset the value of textbox

jQuery('input[type="checkbox"]').on("click",function(){
if(jQuery( "[id='checkboxid']" ).prop('checked')== true)
 {   
jQuery('[id="textboxid1"]').prop("disabled",true);
else {
  jQuery('[id="textboxid1"]').prop("disabled",false);
}
  });




4 replies

Userlevel 7
Badge +36

ricsdpl
You can use the below code and replace the QID appropriately.
Qualtrics.SurveyEngine.addOnReady(function()
{

jQuery("[type='checkbox']").change(function()
  {


    if(jQuery('li').find('label')[0].className == 'q-checkbox q-focused q-checked')
    {
     jQuery('.TextEntryBox.InputText.QR-QID16-1-TEXT.QWatchTimer').prop("disabled",true);
    }
    else
    {
 jQuery('.TextEntryBox.InputText.QR-QID16-1-TEXT.QWatchTimer').prop("disabled",false);
     
    }


  });
});

Presuming your question looks like this:
image.png
Hope it helps!

Badge +2

Deepak how about the reset the value of the textbox
remove the test value in the textbox
image.png

Userlevel 7
Badge +36

ricsdpl
https://community.qualtrics.com/XMcommunity/discussion/comment/51834#Comment_51834You can use below code to remove the placeholder.
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery('.TextEntryBox.InputText.QR-QID16-1-TEXT.QWatchTimer').attr('placeholder', "test");
 jQuery("[type='checkbox']").change(function()
  {




    if(jQuery('li').find('label')[0].className == 'q-checkbox q-focused q-checked')
    {
     jQuery('.TextEntryBox.InputText.QR-QID16-1-TEXT.QWatchTimer').prop("disabled",true);
jQuery('.TextEntryBox.InputText.QR-QID16-1-TEXT.QWatchTimer').attr('placeholder', "");
    }
    else
    {
 jQuery('.TextEntryBox.InputText.QR-QID16-1-TEXT.QWatchTimer').prop("disabled",false);
jQuery('.TextEntryBox.InputText.QR-QID16-1-TEXT.QWatchTimer').attr('placeholder', "test");
     
    }




  });
});
Hope it helps!

Badge +2

Thank you Deepak!

Leave a Reply