1 Why Input Validation Matters
Nearly every injection attack — SQLi, XSS, command injection, path traversal — is made worse (or possible) by missing or insufficient input validation. Validating inputs early and strictly limits the attack surface for every other vulnerability class.
Client-side validation is never sufficient. Any user can bypass it with browser dev tools, curl, or a proxy. Always validate on the server:
// Client-side only — trivially bypassed
if (!/^[a-z]+$/.test(username)) {
alert("Invalid username");
return; // attacker just sends the request directly, skipping this
}