APIs & Integrations

sandracaroline
Participant

Form Jquery onLoad

Hello! I noticed that all the codes im putting in to effect forms in a module wont be read. I have got feedback on this earlier, that I need to use onLoad. I have used the exact same code as recommended, but still it wont be read. I have been trying to use onLoad with no luck. But my code works perfectly in console if i drop the whole code in there. The code works, but jquery wont get read from module

 

module where i want to have disable button if checkboxes is not checked: https://app.hubspot.com/design-manager/4226870/modules/6957699345

 

I also want alot of modules to focus on input fields

 

I want to add a focused cursor on first input field and disable button if GDPR is not checked

 

Appreciate inputs!

2 Replies 2
NHoff6
Participant

Form Jquery onLoad

Using the window's load event is the only way I could use jQuery inside a custom module

window.addEventListener("load", (event) => {
 // Run Jquery here
})

 

0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

Form Jquery onLoad

Hi @sandracaroline ! Is this your previous topic? https://integrate.hubspot.com/t/jquery-not-being-read-properly/15467/4

 

If so, I mentioned that you should use the onFormReady function for the embed code. Since you're rendering our forms using HubL, there's no way to input that callback function. I'd recommend using something other than document.ready such as window.load since the window.load event fires after document.ready. Otherwise, you'll need to create a custom function that listens for the form to load first before firing your code.

 

I edited your function to use the window.load event, and it appears that the code is now working