APIs & Integrations

sandracaroline
Participant

Jquery not being read properly

Hello!

I am trying to make a button disabled if the checkbox is not checked in a hubspot form. Like I did here: http://jsfiddle.net/r58nfqL6/10/

I have tried a few different jquery solutions, but my code doesnt seem to be read. I have added Jquery 1.9.1 library and this is how my code is written at this moment:

jqueryerror

Would appreciate it if someone could correct me on this ! :slight_smile:

0 Upvotes
3 Replies 3
cbarley
HubSpot Alumni
HubSpot Alumni

Jquery not being read properly

Hi @quicklunch, this code doesn't work because in HubSpot forms we don't append any sort of checked attribute to inputs. This code works for me in the console:

$(document).ready(function(){
   $(".hs-button").attr("disabled", "disabled");
   $('.hs-input').click(function(){
	 if(!$(this).attr("checked")){
		$(this).attr("checked", true);
		$(".hs-button").removeAttr("disabled").css({"background" : "#55b949"});
	 } else {
		$(this).attr("checked", false);
		$(".hs-button").attr("disabled", "disabled").css({"background" : "#575757"});
	 }	
   });
});

That said, I wasn't able to get it to work in a custom module in your portal due to the way that we dynamically render forms. We have an onFormReady callback that would work really well with this code, but that's only available within the form embed code

0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

Jquery not being read properly

Hi @quicklunch, can you please link the custom module that you're working on and a test page you have set up so I can take a look?

0 Upvotes
sandracaroline
Participant

Jquery not being read properly

0 Upvotes