Jquery not being read properly

companies

#1

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:


#2

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?


#4

https://app.hubspot.com/beta-design-manager/4226870/modules/6957699345

This is where the disable button code is


#5

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