3 ms·
1. Why do you need to extract forename+surname? The assumption that your users will even have a forename and a surname is invalid. [http://www.kalzumeus.com/20
by oconnore 15y ago
1. Why do you need to extract forename+surname? The assumption that your users will even have a forename and a surname is invalid.
[http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-b...]
2. There are exactly 50 states, so 50 names and 50 abbreviations. You are expecting the data in "City, State" format, so you parse the form in Javascript when the user finishes typing. If the data after the comma matches one of 100 strings, turn the form green, otherwise turn the box red.
3. Put the expected representation in the label. Parse the form as the user is typing, and replace the date with your interpretation when the box loses focus ("01/23/12" => "January 23, 2012") Turn the box red if the month is > 12 or the day > 31.
If the user has Javascript disabled, display a verification screen after the form is submitted.
- bena 15y ago"You are expecting the data in "City, State" format" This is a bad assumption. What you should do is throw away commas, split along whitespace, and then see if the last element split is a valid state or territory. Because some lazy guy will type "new orleans la" and just ruin your day.
- masterzora 15y agoAnd then some non-lazy guy types in Albuquerque New Mexico and you find that Mexico is not a US State. I know, this isn't a particularly difficult thing to work around, but I was amused that you replaced one bad assumption with another.
- bena 15y agoOh well, getting closer. ;) We could always start taking from the back and doing look ups until we have a match or we finish the string.
- pavel_lishin 15y agoDallas, TX, 75254. Is "." a state? How about "75254"?
- ZeroMinx 15y ago"2. There are exactly 50 states, so 50 names and 50 abbreviations." Considering the Internets is a really really big place (not just America), that statement is rather quite false.
- jameshart 15y agoStrange to, on one level, make the valid and useful observation that forename + surname is a cultural assumption, then go right ahead and make the cultural assumption that the form should only accept US addresses (and even then ignoring DC, PR, Guam, and forces serving overseas...). Even with your scheme, you'd better hope nobody types in Beverly Hills, LA. And you'll need a spellchecker to help out people who can't spell Missississississippi.
- robfig 15y agoIt's not necessarily a "cultural assumption" -- many companies only do business in the US. However, people of any ethnicity may reside here. Seems consistent to me. I agree that splitting the city state is probably more complicated than it's worth though.
- zbanks 15y agoIt seems like a reasonable assumption for a user to know the two-letter abbreviation of the state they live in. If you suggest otherwise, how do we know that they can spell their street correctly?
- pavel_lishin 15y agoBut is it a reasonable assumption that they'll enter the abbreviation, instead of the state name?
- jameshart 15y agoThe question here though is not whether people can spell things correctly or correctly identify what state they live in, as whether you can write a computer program to, given what someone claims is their address, reliably break it down into parts to, for instance, extract what state they live in. If you give someone separate fields for 'city' and 'state' you have some chance of figuring out where they are located if they type 'Washington' into one of those fields. If you ask them just for 'city, state', some people will understand that as 'city or state' and just type 'Washington', and you have no idea what they mean. The example I gave before, LA, is an example of a city which shares its name with a state abbreviation. An anecdote for you: I was once working with UK callcentre system which had a form for callcentre staff to update customer contact addresses. UK postcodes are combinations of letters and numbers, and certain letters are excluded from certain positions to prevent ambiguous handwritten letterforms causing confusion. I naively implemented strict postcode validation, thinking it would help catch data entry errors. What actually happened was that we ended up, in a significant number of cases, telling people that the postcode that they had been using as part of their address for decades was not, in fact their postcode - it couldn't be because it was an invalid postcode. This made the customers quite cross, and we had to change it. Do you want your validation message to be the one to break it to some eighty year old guy that Nebraska is actually NE, not NB any more?
- smackfu 15y agoThere are actually 8 more non-states (like MP, AS, PR), and 6 for overseas military. Just to cover the US.
- DrJokepu 15y agoOften, you have to have a first name and last name due to various business / legal constraints. There is no way around it, even though, as you've correctly said, not everyone has a first name and a last name. Unfortunately lawmakers are often not culturally sensitive enough to understand that.
- saurik 15y agoWhat is an example of such a legal constraint? (The only name-related legal compliance issues I can come with off the top of my head demand "full name".)
- pavel_lishin 15y ago> 2. There are exactly 50 states, so 50 names and 50 abbreviations. Quick, spell the state that starts with "M" and ends in "ets"! How about "M"-"pi"? "T"-"see"? I know, it's almost trivial to guess at misspellings. But that's just another piece of code you have to write.
- spc476 15y agoNot if you know what to look for. I came across code that implements the metaphone algorithm (http://en.wikipedia.org/wiki/Metaphone http://en.wikipedia.org/wiki/Metaphone) and used it for a sample project I started, but never finished, years ago (http://boston.conman.org/cgi-bin/location/location.cgi http://boston.conman.org/cgi-bin/location/location.cgi). It could be modified to allow free form text, instead of the text field for the city, pull-down for the state, but that's an implementation detail. But the point is---code to check for misspellings already exists.
- Hyena 15y agoWhy even bother with the state? Just get the postal code. Hell, just let the user write in the postal code and use their IP address to match it with the country of residence. They can put any number in there and you can match it to some location. No states. No assumptions. Well, beyond the one about IP address being accurate, I guess.