Required Info Fields

If you want to collect personal information about someone on a site, say before you let them download software or something, why would you not validate the form fields. If you’re extreme, you’ll check the existence of the address, even. Or do one of those email loop-back checks (send the URL of where to download via email, so you’ll at least get a real email address). But even if you don’t do any of that, it makes sense to at least validate the format of the entry. Phone numbers, email addresses and zip/postal codes all follow standard formats that are easy to test against. Phone numbers should be all numeric (apart from perhaps parentheses, hypens, periods and spaces). Zip & postal codes both follow standard formats. There’s only so many permutations of email addresses. and if there’s no @ or two .s in a row, you know it’s bad. A quick Google will give you a variety of regular-expression match cases for all of these. So go on, validate your forms, or don’t bother having them at all.

12 Replies to “Required Info Fields”

  1. On the subject of form validation, in my experience, it’s not always as straightforward as all that. US ZIP codes follow a certain format, sure, but postal codes from other countries do not. Some are numeric, some are alphanumeric, some allow spaces (and other characters), some don’t. Same goes for phone numbers, even different types of credit cards have a different number of characters. It’s a minefield – who’d be a web developer eh?

  2. On the subject of form validation, in my experience, it’s not always as straightforward as all that. US ZIP codes follow a certain format, sure, but postal codes from other countries do not. Some are numeric, some are alphanumeric, some allow spaces (and other characters), some don’t. Same goes for phone numbers, even different types of credit cards have a different number of characters. It’s a minefield – who’d be a web developer eh?

  3. Brishen: I guess my point is that if you don’t validate, why bother in the first place? I’m sure most people just put in tripe.
    Rob: Well, you’ll know your audience is my answer to that. For credit cards, you can base it on your merchant account and location. Zip codes, actually all follow some fairly basic formats that can be checked (some places have handy things like a checksum too). Phone numbers, even if all you’re checking is that they’re numerals, it’s something. But you are right – international validation is a nightmare – I’ve only personally ever written validation for North American users.

  4. Brishen: I guess my point is that if you don’t validate, why bother in the first place? I’m sure most people just put in tripe.
    Rob: Well, you’ll know your audience is my answer to that. For credit cards, you can base it on your merchant account and location. Zip codes, actually all follow some fairly basic formats that can be checked (some places have handy things like a checksum too). Phone numbers, even if all you’re checking is that they’re numerals, it’s something. But you are right – international validation is a nightmare – I’ve only personally ever written validation for North American users.

  5. That’s just my point. When you’re developing for a sepcific audience, e.g. North America, you can know your audience. But when you have customers all over the world, it becomes a real headache. It is possible to do, but it just takes way more time and research.

  6. That’s just my point. When you’re developing for a sepcific audience, e.g. North America, you can know your audience. But when you have customers all over the world, it becomes a real headache. It is possible to do, but it just takes way more time and research.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.