You built a login form. It looks clean, it shows a red message when the email is wrong, and you feel done. Then someone sends your server a request your form would never allow, and it walks straight in. Today I'll show you why every form needs two checks, what each one is for, and how to build both so they stop fighting each other.
Here's the short answer, so you have it before anything else. Form validation runs twice on purpose. The check in the browser is for the person filling in the form: fast, friendly feedback before anything is sent. The check on the server is for your app: it's the only one you can trust, because anyone can skip the browser and talk to your server directly.
That's it. Everything else in this article is the why and the how. If you're a beginner, read it top to bottom. If you already write client-side validation every day, jump to the section about the browser check being a courtesy, not a lock.…