I have an embedded HS form on a HS page. It works fine in Chrome, but it looks like onFormSubmit never gets hit when using an iPhone. Anyone else experience that, or have thoughts on it?
Hey @SRalston05 - thanks for posting in the Community!
Can you please provide a bit more context around what’s happening when you click “submit” on the form in a mobile browser? Specifically, are you not at able to click “submit” at all, does it lead to any type of error, does it appear to submit but not show up in your form’s Submission page, etc?
I also found this Community Post, which seems to inquire about a similar situation. Can you also clarify what type of mobile device you’re using, as well as if this behavior is consistent across all types of mobile devices?
Shane, Community Manager
I’m using an iPhone 7 for my Apple testing. As a kind of cobbled-up troubleshooting setup I have a script in place that writes all console messages to a log file on the server.
The form embed code in question is in the html source of an html element in the template. The code starts with:
hbspt.forms.create({
This code:
onFormReady: function($form) {
console.log(“onFormReady”);
runs on both the iPhone and an Android phone.
This code:
onFormSubmit: function($form) {
console.log(“onFormSubmitted, html for the form”);
does not run on the iPhone.
UPDATE: With more testing I realized the onFormSubmit code block does execute, but console.logs don’t fire, making it very difficult to troubleshoot. I put alerts() in that code block, they fire.
So, my apologies, I guess that particular problem is in my hack that writes console data to a log file.
BUT, submissions from the iPhone don’t trigger the Hubspot notification email. I get notifications for submissions on Android and PC, but not iPhone.
Steve
I’ve seen this pop up before, @SRalston05 and it’s usually less about HubSpot itself and more about how Safari on iOS handles form overlays and scripts.
In a very similar thread, another user discovered that a hidden or absolutely-positioned element was sitting on top of the submit button on mobile, so taps never actually hit the onFormSubmit event. On desktop Chrome it looked fine, but mobile Safari was stricter about click targets. (That “other post similar” is here if useful: (https://community.hubspot.com/t5/CMS-Development/CTAs-not-working/m-p/947642 )
A quick test is to open Safari’s Web Inspector with your iPhone connected and check if there’s any CSS element covering the button. You can also try temporarily removing custom CSS around the form embed to confirm. HubSpot’s embed code itself should fire onFormSubmit on mobile the same way it does on desktop (https://developers.hubspot.com/docs/cms/start-building/building-blocks/modules/forms )
So if the callback isn’t triggering, chances are the click never reaches it.
If you confirm it’s only happening on iPhone Safari and not Android Chrome, I’d start by checking for overlays, z-index issues, or event listeners that hijack touch events. Once the button is truly clickable, onFormSubmit should work as expected. Hope this helps track it down.