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


#1

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


#3

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.