Hi @John_Wachunas and @Sergey_Smirnov, apologies for the delay - I'm not sure how this topic slipped through the cracks. If I'm understanding you correctly your process is as follows:
- Visitor submits form
- Perform lookup based on location data
- If the visitor's location is serviceable, redirect them to site
- If the visitor's location is not serviceable, display thank you message
Are you looking to completely replace this process you currently have with native HubSpot Forms on a HubSpot hosted site, or keep your external site but just replace your forms with HubSpot forms?
EDIT: To add some more color here: If you're looking to replace your forms with HubSpot forms, I don't see a way to do this. We have some built in callback functions like
onFormSubmit, but none that would fit your needs.
onFormSubmit will fire just after clicking the submit button, but just before the data is submitted.You cannot stop the submission, wait for an AJAX call, and then finally submit the data --the code in the
onFormSubmit function is run and the data is sent immediately. From your setup, it sounds like you'd need to make a GET to your endpoints just after the contact submits the form but just before the data is sent so that you could handle the redirect logic. Unfortunately, I don't see a way we could do this unless you somehow fire the Ajax call just after the user clicks out of the field where they submit their location (could use the blur event with JQuery), to populate the dropdowns. Even then, a HubSpot form's dropdown values are not able to be overwritten or added to so this wouldn't be a viable solution. I'd suggest using the forms API to submit data to HubSpot after you've handled your redirect logic and continuing to use custom forms.