A custom form pasted into a WordPress Custom HTML block looked fine, but clicking Submit just reloaded the page, or dropped the visitor on the site homepage. No request ever reached the form service and no email arrived. The browser console held one clue: “Uncaught SyntaxError: Invalid or unexpected token.”
A Form That Reloads to the Homepage Usually Means Its Script Never Ran
⚡ Quick Fix (TL;DR)
The Culprit: WordPress ran the inline script through its text-formatting filter, which swaps straight quotes for curly ones. That broke the JavaScript before it could attach its submit handler. With no handler and no action attribute on the form, the browser fell back to a plain native submit, which just reloads the current page.
The Fix: Encoded the script as base64 and ran it with eval(atob(…)), which gives the filter no quote characters to rewrite. Loading the script from an external .js file avoids the same problem. The tell worth remembering: if a form "does nothing" or bounces to the homepage, check the console for a syntax error first. Don't start by suspecting the form service or its API key.
Tagged in :