Netlify Forms Are failing on first post only

Alright, I really want Netlify forms to work. The simplicity is awesome. However, I’m running into a very odd bug. I have two forms, on completely different pages, on a Sveltekit site. One form is here:

https://ericabraley.com/contact

And the other is here:

https://ericabraley.com/plan-your-session/newborn-sessions

The code for the contact form is here:

<form method="POST" name="Contact" data-netlify="true" action="/thankyou">
        <div class="info">
            <input type="text" name="Name" placeholder="Name" required>
            <input type="email" name="Email" placeholder="Email" required>
        </div>
        <textarea rows="10" placeholder="Message" name="Message" required></textarea>
        <div class="button-bar"><button type="submit">Send</button></div>
    </form>

And the code for the second form is quite long, so I can’t paste it here. However all fields are uniquely named, both forms are uniquely named, and I set prerendering in Sveltekit to true on both these pages, so they shouldn’t have any issues in that department. The exact bug is as follows:

The contact form almost always displays a “page not found” error on the FIRST submission in a fresh session. If you hit back, and resubmit, it works every time after. This started after I added the second form. I have reviewed the megathread for support issues with forms, and none of the problems really matched mine. Furthermore, it’s weird to me that it only fails the first time it’s submitted.

I’ve tried deleting and redeploying the forms to ensure the field names still match, I’ve triple checked all my names are unique, etc. As far as I can tell, it’s a compliant HTML5 form. Any ideas?

As a final note, don’t judge the site design itself too closely, it had to be pushed to prod prematurely :stuck_out_tongue:

Hi @ryanboddy , welcome.

If you have not read the resource below kindly do so as will be help with properly configuring your form with Sveltkit on Netlify.
Thanks.

1 Like

I had read through this, but somehow missed the hidden input field. I’m not sure why it’s needed, but I won’t question black magic. It seems to have solved the issue! Thanks

2 Likes