# Controlling a native Hubspot form using api or javascript

**URL:** <https://community.hubspot.com/t/controlling-a-native-hubspot-form-using-api-or-javascript/36898>\
**Category:** APIs & Integrations\
**Tags:** email, forms\
**Created:** [May 7, 2021, 3:45am UTC](https://community.hubspot.com/t/controlling-a-native-hubspot-form-using-api-or-javascript/36898 "2021-05-07T03:45:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![justwil](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/justwil/32/30597_2.png) [@justwil](https://community.hubspot.com/u/justwil)\
**Post date:** [May 7, 2021, 3:45am UTC](https://community.hubspot.com/t/controlling-a-native-hubspot-form-using-api-or-javascript/36898/1 "2021-05-07T03:45:27Z")

</div>

Hey Guys,

We have been getting an insane amount of spam emails through our lead forms. Captcha isnt working and blocking the domains are not working as well. We decided to sign-up for Neverbounce and use their API to validate the email address on the form.  
Are you able to control a native Hubspot form using the API or Javascript on the the Hubspot landing page? Can i can control it by stopping the form submission and connecting the Neverbounce API to validate the email address and if its valid…submit the form?

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [May 7, 2021, 3:55pm UTC](https://community.hubspot.com/t/controlling-a-native-hubspot-form-using-api-or-javascript/36898/2 "2021-05-07T15:55:30Z")

</div>

Heyo @justwil

Sorry about the spam issue 😞

You can look at [this doc](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options) for how you can customize the form embed code. I believe you will want to look at the onFormSubmit callback

---

<div class="post-metadata">

**Author:** ![justwil](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/justwil/32/30597_2.png) [@justwil](https://community.hubspot.com/u/justwil)\
**Post date:** [May 7, 2021, 4:02pm UTC](https://community.hubspot.com/t/controlling-a-native-hubspot-form-using-api-or-javascript/36898/3 "2021-05-07T16:02:52Z")

</div>

Thanks @dennisedson!

According to this post: [https://community.hubspot.com/t5/APIs-Integrations/Prevent-Form-submission-after-successful-Validation/td-p/317171,](https://community.hubspot.com/t5/APIs-Integrations/Prevent-Form-submission-after-successful-Validation/td-p/317171) It’s not possible to control the form using the onFormSubmit callback. Another thing is that im not using the form embed code becasue my website is hosted in Hubspot…im using the form builder in Hubspot. On top of that, i tried that exact same code (outside of hubspot… externally) in that post using the onFormReady callback and it didn’t work.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [May 7, 2021, 4:08pm UTC](https://community.hubspot.com/t/controlling-a-native-hubspot-form-using-api-or-javascript/36898/4 "2021-05-07T16:08:56Z")

</div>

@justwil

You aren’t trying to not submit the form, correct? You just want to delay it for additional validation via this third party API. Am I reading that correctly 😬

You can use the embed code in HubSpot. You could make a custom module for it for easy use for the marketing team.

@alyssamwilie , @dbeau79 can either of you offer some advice here?

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [May 7, 2021, 4:45pm UTC](https://community.hubspot.com/t/controlling-a-native-hubspot-form-using-api-or-javascript/36898/5 "2021-05-07T16:45:12Z")

</div>

@justwil I’ve not done this before but this article shows you how to prevent submit, add custom validation, and submit after that validation is successful within onFormReady using Query Validation Plugin. If Neverbounce has similiar functions you can plugin into you might could pull off the same mechanics.  
[https://rschu.me/prevent-the-submit-of-any-hubspot-forms-after-a-successful-validation-5e1f230b14f1](https://rschu.me/prevent-the-submit-of-any-hubspot-forms-after-a-successful-validation-5e1f230b14f1)  
If you don’t want to use the embed code for the form you can use an event listener to use the callbacks.

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Freference%2Fcms%2Fforms)**
