APIs & Integrations

nutan1
Participant

Is it possible in hubspot to use jquery events on form fields(For e.g jquery blur event)

SOLVE

Is it possible in hubspot to use jquery events on form fields(For e.g jquery blur event)

0 Upvotes
1 Accepted solution
cbarley
Solution
HubSpot Alumni
HubSpot Alumni

Is it possible in hubspot to use jquery events on form fields(For e.g jquery blur event)

SOLVE

Hi @nutan, yes you can add jquery events on form fields if you're using the form embed code and have a marketing basic, pro, or enterprise portal. You can use the onFormReady or onFormSubmit callback functions to add in a blur type of functionality. For example, I have the following code on this page:

<script>
  hbspt.forms.create({
    portalId: "XXXXXXX",
    formId: "983fd305-bdd3-XXXXXXXXXXXXX",
    css: ".submitted-message {color: green;}",
    inlineMessage: "hello <br> friend",
    onFormReady: function($form) {
    	$('input[type="email"]').blur(function(){
      	    alert("Blur event was called");
    	});
    } 
  });
</script>

If you click into the email fields and then click out, you'll see that event fire.

View solution in original post

1 Reply 1
cbarley
Solution
HubSpot Alumni
HubSpot Alumni

Is it possible in hubspot to use jquery events on form fields(For e.g jquery blur event)

SOLVE

Hi @nutan, yes you can add jquery events on form fields if you're using the form embed code and have a marketing basic, pro, or enterprise portal. You can use the onFormReady or onFormSubmit callback functions to add in a blur type of functionality. For example, I have the following code on this page:

<script>
  hbspt.forms.create({
    portalId: "XXXXXXX",
    formId: "983fd305-bdd3-XXXXXXXXXXXXX",
    css: ".submitted-message {color: green;}",
    inlineMessage: "hello <br> friend",
    onFormReady: function($form) {
    	$('input[type="email"]').blur(function(){
      	    alert("Blur event was called");
    	});
    } 
  });
</script>

If you click into the email fields and then click out, you'll see that event fire.