The 3 Deadliest Sins of Form Validation

Why You Probably Shouldn’t Validate an Email Address with Regex and Other Deadly Sins

Bret Cameron
The Startup

--

Forms are an integral part of the web. For businesses, they provide an essential way of growing and maintaining a customer base. For users, they’re tedious but necessary. As web developers, it’s our job to cater to both groups. We should aim to make forms as quick and painless as possible, while also ensuring the data we collect is useful and valid.

And yet the web is full of terrible form validation. Maybe it’s because we underestimate the complexity involved. Maybe we find forms as boring as our users. But the end result is frustrating for everyone: we end up with forms that don’t accept legitimate data, and that either turns users away or it forces them to submit incorrect information.

In this article, I’ll share what I believe to be the three deadliest sins of form validation — and what you can do to avoid other people’s mistakes.

1. Email Addresses

Several of the ‘deadly sins’ in this article involve regular expressions — a.k.a. regex. Used well, regular expressions provide a succinct solution to finding and manipulating substrings. But the internet is also full of less-than-perfect regex, which is either too strict —…

--

--

Bret Cameron
The Startup

Writer and developer based in London. On Medium, I mainly write about JavaScript, web development and Rust 💻