I’m trying to set a character count limit on a text field on an embedded HubSpot form. I found a jQuery example which I’ve added to my code but it doesn’t seem to work. Any ideas what’s wrong?
The form loads and submits just as it should. The character limit just doesn’t work. There are no console errors on form submission either.
Hi Isaac,
Thanks for your response. I should’ve noticed that the field is different!
I corrected the code but for some reason, the maxlength attribute is not added to the HTML tag when I check it on browser developer tools (Firefox). Is it possible that some of the new form styling options on HubSpot are affecting this?
It’s possible. Could you DM me a link to your form and/or landing page so I can take a closer look?
P.S I will be out of office from April 30 - May 8, so if you need an answer more quickly, please feel free to create another post citing this one or contact HubSpot support.
Sincere apologies for the delayed response. Since leaving Developer Support, I check the Community less frequently.
While it is not possible to impose a character limit on multi-line text fields in HubSpot’s forms editor, as long as the form element is not rendered in an iframe (as with Free or Starter subscriptions), you can modify the form using HubSpot’s global form events and the JavaScript discussed above.
Said differently, you do not have to modify the form’s embed code to use the onFormReady global event to trigger custom JavaScript validation.