You are viewing limited content. For full access, please sign in.

Question

Question

Prevent collapse if info is entered

asked on August 23, 2018

I have four sections that are expandable on a form.  If the submitter enters information, I would like to disable the collapse feature to avoid overlooking information.  Can this be done?

Here is a snip of my expandable/collapsible sections.

0 0

Answer

SELECTED ANSWER
replied on August 24, 2018

Great question! A little bit of javascript will do this for you:

$(document).ready(function(){

// The #q7 is the id field of my input field, in your case any field that should trigger this action
//You can have multiple fields that trigger this too if you wish, for each section!
   $("#q7 input").change(function(){
    var field1 = $("#q7 input").val();
    
	if (field1 !== "") {
// My Section id is #q6 so you will change yours to fit what you need
      var element = document.getElementById("q6").getElementsByClassName("collapsible")[0];
      element.classList.remove("collapsible");
   }
     else {}
  });
  
});

Let me know if that works for you!

0 0
replied on August 27, 2018

This worked great.

Thanks.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.