On this page
What this issue is
Most JavaScript error checks look at page load. This issue is different. The page loads with a clean console, the form looks normal, and the error only appears when someone clicks submit. The code that runs on that click throws an exception, and the form stops partway.
The code running on submit is usually one of these: a validation script, a custom submit or click handler, a tracking call (for example a conversion event that reads a field that does not exist), a CAPTCHA callback, or a script that builds the request to send to your CRM. If one of them throws, later code in the same handler never runs. That can include the code that actually sends the form.
Why it costs you leads or sales
The visitor has done the hard part. They found your page, filled in the form and clicked. If the click ends in a script error, they usually see nothing: no thank-you message, no error, no page change. Most people click once or twice more, then leave.
- Landing pageLoads with a clean console
- Fill in formFields accept input
- Click submitHandler throws an error
- Form request sentNever runs
- Lead in inbox / CRMNothing arrives
- Conversion trackedNo thank-you event
The page and the form work. The break happens in the click handler, so everything after it is lost.
Example: the same traffic, but a theme update introduces a submit error in week 3. Numbers are illustrative.
How to check if your site has it
You have to reproduce the click. Looking at the page is not enough.
Open DevTools before you click
Press F12 (or Cmd+Option+I on Mac) and open the Console tab. Tick Preserve log so the error stays if the page reloads.
Fill in the form with test data
Use a clearly fake name and an email you control. Fill in every field the way a real visitor would.
Click submit and read the first red error
Note the message and the file and line number on the right. The first error matters most, because later ones are often side effects.
Check the Network tab
If no request to your form endpoint appears after the click, the script stopped before sending. If a request appears with a 4xx or 5xx status, that is a different problem (server side).
Repeat in a private window and another browser
A private window with extensions off rules out browser add-ons. A second browser shows whether the error is browser specific.
| Console message | Likely cause | Where to look |
|---|---|---|
| Cannot read properties of null (reading 'value') | Script looks for a field that was renamed or removed | Custom validation or tracking code |
| x is not a function | A library did not load, or loaded twice with a clash | Script order, duplicate jQuery |
| x is not defined | A variable such as dataLayer or fbq is missing | Tag or pixel snippet |
| Uncaught (in promise) TypeError | An async call failed and nothing handles it | Fetch or CRM integration code |
| Failed to execute 'submit' on 'HTMLFormElement' | A field is named submit and hides the submit method | Form markup |
How to fix it
The error message tells you which script to fix. Fix the cause, not just the symptom. Wrapping everything in a try/catch hides the error but may still leave the form unsent.
Find the file and line
Click the file link next to the error in the Console. Note whether it is your theme, a plugin, a tag manager script or a third-party widget.
Disable the suspect script and test again
Turn off the plugin, tag or snippet and submit again. If the error goes away, you have found the source.
Correct the code or update it
Fix the selector, add a null check, or update the plugin or theme to a version that matches your current form.
Make tracking code fail safely
Tracking should never block the form. Guard calls so a failure in analytics cannot stop the send.
Submit again and check the lead arrives
Confirm the console is clean, the network request succeeds and the test lead reaches your inbox or CRM.
document.querySelector('#lead-form').addEventListener('submit', function (event) {
// Tracking is optional: never let it stop the form.
try {
var emailField = document.querySelector('#email');
if (emailField && window.dataLayer) {
window.dataLayer.push({ event: 'generate_lead' });
}
} catch (err) {
console.warn('Tracking failed', err);
}
// The form then submits normally.
});Find the culprit plugin
Use the file path in the error. Paths containing /wp-content/plugins/name/ point to that plugin. Update it, or deactivate plugins one by one and retest the form.
Check theme and form plugin versions
A form builder (Contact Form 7, Gravity Forms, WPForms and similar) can clash with a theme or optimisation plugin. Update all three.
Exclude the form scripts from JS optimisation
If a caching or minify plugin combines, delays or defers JavaScript, exclude the form plugin's scripts and jQuery, then clear the cache and test again.
Check theme code and apps
In Online Store > Themes, look at recent edits. Disable recently added apps under Settings > Apps and sales channels, or turn off their app embeds in the theme editor, then retest.
Look at custom pixels
In Settings > Customer events, a faulty custom pixel can throw errors. Disconnect it and retest.
Use Preview mode
Start Tag Assistant preview, submit the form and check which tag or Custom HTML tag fires at the time of the error.
Fix or pause the Custom HTML tag
Add null checks, or pause the tag, then publish a new container version once the form submits cleanly.
Check custom code
Look in Site settings > Custom code and in page-level Custom code, plus embed elements near the form. Remove or fix scripts that read fields by an old class or ID.
Check field names
If you renamed a field, update any script that references it, then publish and test on the live domain.
Review custom code in the funnel or form
Check the funnel's tracking code and custom JavaScript blocks, plus any script embedded on the page that reads form fields.
Test with scripts removed
Remove custom scripts one at a time and resubmit to find the one that throws.
Check Custom Code and Velo code
In Settings > Custom code, review added snippets. If you use Velo, open the page code and check the submit or onClick handler for references to elements that no longer exist.
Check code injection
Open Settings > Advanced > Code Injection and any Code Blocks on the page. Remove or fix scripts that touch the form, then retest.
Use the stack trace
Enable source maps for staging, click submit and follow the trace to the exact line in your source.
Handle failures in async code
Use try/catch around await calls and show the visitor a clear error message if the send fails.
How to confirm it's fixed
- The Console shows no red error after you click submit
- The Network tab shows the form request with a 2xx status
- The visitor sees a thank-you message or page
- The test lead arrives in your inbox and CRM
- Your conversion tag fires once on success
- The same result in Chrome, Safari and a mobile browser
- The same result in a private window with extensions off
Before
- Console shows an uncaught TypeError on click
- No network request to the form endpoint
- Visitor sees nothing happen
- No lead, no conversion event
After
- Console stays clean on click
- Form request returns a 2xx status
- Thank-you message or page shown
- Lead and conversion event both recorded
How to prevent it happening again
- Test a full form submission, not just the page load, after every theme, plugin or tag change
- Keep tracking code wrapped so it cannot block the send
- Avoid renaming field IDs or classes without searching your scripts for them
- Publish tag manager changes in preview first and submit the form in preview
- Update form plugins and themes in a staging copy before production
- Run a scheduled test that submits the form and checks the lead arrives
Day 0
A plugin or tag update changes how the form is built. The page still looks fine.
Day 0
The first visitor clicks submit and the handler throws. Nothing is sent.
Day 1-3
Leads drop, but ad spend and traffic look normal, so nobody investigates.
Day 4
Someone submits the form by hand, sees the error and traces it to the script.
Day 4
The script is fixed and leads return. Example timing only.
How FunnelGuard handles this
FunnelGuard detects this issue today. A robot visitor runs your real form journey on a schedule, fills in the form and clicks submit. It records console errors at each step, including the ones that only appear after the click, and checks whether the submit actually worked.
If a step fails, FunnelGuard re-checks from a second region before it sends one alert (email, Slack, Teams, WhatsApp, webhook or PagerDuty) with a screenshot and a likely cause. It can also check whether the test lead reaches your inbox and CRM, and whether tracking hits are sent. Test traffic is marked with utm_source=funnelguard and fg_test=1, and it never bypasses CAPTCHAs or bot protection. If your form is protected by one, the test may not be able to complete the submit.
Questions people ask
Why does my form show a JavaScript error only when I click submit?
The code that runs on submit (validation, tracking, a CRM call or a CAPTCHA callback) is different from the code that runs on page load. If one of those scripts looks for a field that is missing or a library that did not load, it throws only at that moment. Open the Console, click submit and read the first red error to see which script it is.
Why is my submit button not working and nothing happens?
Often a script error stops the click handler before the form is sent. Open DevTools, go to Console and click the button. If you see a red error and no request in the Network tab, a script is breaking the submit.
How do I find which script breaks my form on submit?
Click the file name next to the error in the Console. A path in /wp-content/plugins/ points to a WordPress plugin, and a tag manager script points to a Custom HTML tag. Disable that script, resubmit, and if the error is gone you have found it.
Can a tracking pixel stop my form from submitting?
Yes. If a tracking call runs inside the submit handler and throws an error, the code after it may never run, including the send. Wrap tracking in a try/catch or load it so it cannot block the form.
Will I get an error email when a form fails because of JavaScript?
Usually not. The browser throws the error, and your server never receives a request, so it has nothing to report. You only notice through fewer leads or by testing the form yourself.
How can I monitor my form for submit errors automatically?
You need a test that fills in and submits the form on a schedule and watches the console. FunnelGuard does this with a robot visitor, checks the step, the tracking hits and whether the test lead arrives, and alerts you with a screenshot and likely cause.
Is a try/catch around the submit handler enough to fix it?
No. It hides the error from the console but does not fix the broken script, and the form may still not send. Fix the root cause, then confirm a test lead reaches your inbox or CRM.
Related issues
- PRF-117Console error on a funnel stepFix guide
- PRF-118Unhandled promise rejectionFix guide
- PRF-134Button does nothing on click (dead click)Fix guide
- PRF-135Form submits but shows no feedback (silent failure)Fix guide
- PRF-137Error 'Something went wrong' shown after submitFix guide
- PRF-136Double-submit creates duplicate leads/ordersFix guide