7 ms·
1. How do you reliably extract forename+surname from a single name field 2. Same for the City/State field 3. Half the world will enter dd/mm/yy and half will
by andybak 15y ago
1. How do you reliably extract forename+surname from a single name field
2. Same for the City/State field
3. Half the world will enter dd/mm/yy and half will enter mm/dd/yy for date of birth (and the geeks will enter yy/mm/dd ;-). How do you check for that error?
- deleted 15y ago[deleted]
- nantes 15y agoNo answer for 2 or 3, but I have been thinking about 1 for awhile. My notion is to ask the user for a common name and a formal name. So something like ... Common name -> Joe Formal name -> Joseph A. Smith Common name would be used for interaction with the user, and formal for anything requiring it (e.g. legal, billing, shipping). Just a thought and one that I have yet to try.
- wccrawford 15y agoI once saw a site that asked for full name and nickname. After I got over the shock of it being different, I quite liked it. It always knew what to call me, and never made assumptions.
- jamesteow 15y ago1. Good point. 2. Probably should have an autocomplete feature. 3. Sometimes I see forms specifically mention what format they want.
- oconnore 15y ago1. 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.
- pornel 15y ago1. You just can't do it reliably, because there are people (entire nations/cultures) who don't even have names fitting first/last model. It's a can of worms, very well explained here: http://www.w3.org/International/questions/qa-personal-names http://www.w3.org/International/questions/qa-personal-names and here's an interesting edge case: http://www.chaos.org.uk/~wookey/name.html http://www.chaos.org.uk/~wookey/name.html 3. <input type=date> will use localized format for editing (browsers are free to use any format/calendar widget), but always send YYYY-MM-DD to the server.
- imurray 15y agoand the geeks will enter yy/mm/dd More precisely, I think many geeks will enter YYYY-MM-DD — http://www.cl.cam.ac.uk/~mgk25/iso-time.html http://www.cl.cam.ac.uk/~mgk25/iso-time.html — having lived on two continents, I use this format whenever I can.
- Deprecated 15y agoBeing an old VMS fan, I always liked DD-MMM-YYYY (e.g. 29-Jul-2011). At least it eliminates the month day ambiguity which sometimes confuses me.
- kiiski 15y agoBut then you lose most of the advantages mentioned in the linked summary.
- hammock 15y agoReadability increases but sortability decreases with ddmmyy as opposed to yymmdd. Readability increases. Dates we use in day-to-day work are probably power-law distributed going backwards with more recent dates being more common. That means if most of the dates will have year 2011, we can guess that, and the day and month become more important. And if most of the months will be current or previous month, we can guess that too and day emerges as the most important piece of info- we will want to read that first. The yymmdd is less readable because it gives us information we (probably, given the power-law distribution mentioned above) already know first, such as the year. But you lose sortability, yeah.
- billswift 15y agoSame here. I started using YYYY-MM-DD for my own use as soon as I learned of it, long before I was on the internet. Among other things even the simplest sort programs will get dates in the right order.
- rmc 15y ago1. How do you reliably extract forename+surname from a single name field You don't. You should never tell someone that their name is invalid. it's their name
- ktsmith 15y agoThis is true in most cases but not all. I deal with data going onto government forms, see lots of work visas etc. The U.S. government is more than happy to tell you that your name is invalid, or data enter garbage into their databases to make the name conform to the standard. Then we have to enforce the same standards on our users even if it doesn't make sense because we have to exactly match what the governments records contain.
- saurik 15y agoCan you provide an example of such a document from the US government that requires a split apart first/last name? I am not saying you are wrong: I am simply deeply curious (as the ones I have dealt with ask for "full name").
- ktsmith 15y agoThe Form I-9 is one example: http://www.uscis.gov/files/form/i-9.pdf http://www.uscis.gov/files/form/i-9.pdf The Form W-4 is another. http://www.irs.gov/pub/irs-pdf/fw4p.pdf http://www.irs.gov/pub/irs-pdf/fw4p.pdf For employers enrolled in the E-Verify program having incorrect name data on the Form I-9 can start a process where an employee is flagged as possibly not being eligible to work in the US.
- saurik 15y agoSo, the pattern that I found in all of the documents I dealt with, is that if you are filling in /your/ name, it might ask you to break it apart, but if you are filling in /someone else's/ name, it asks for "full name". As you are not supposed to be filling in the name field on an I-9 or a W-4 for your employees, so you should not end up in a situation where your internal wbaite (or whatever) that asked for "full name" screws you. However, note that the "new name" field on the I-9, which is an area of the document you fill out, is not broken apart by first/last.
- masklinn 15y ago> 1. How do you reliably extract forename+surname from a single name field You don't. It's their name, it is not broken. Instead, the "first name, last name" format is broken: what happens if that person has more than two names? If they're culturally written last, first instead? If their first or last name should never be used on its own? Or if only one of them should be used? You ask for their name, and you use what they give you. Period, end of the story. You have no business fucking up somebody's name. > 2. Same for the City/State field That one's even easier: freeform address. Not everybody has a state, not everybody needs a city field, and not every address can fit in so simple a format. Ever seen a japanese address? There are 5 or 6 levels in the geographical hierarchy (country, prefecture — including prefecture type, municipality, optionally ward (depends on municipality size), district, block and house number) and it's written from the largest to the smallest element of the hierarchy (so prefecture to house number). With the business or person name at the end. You may also note that japan does not generally use street-based addresses, though some local systems do (no, japan does not use a single unified postal addressing system either)
- JacobAldridge 15y agoYour point 1 is exactly the question I came here to see answered. The article actually claims "Another benefit to unified text fields is getting the user’s information in a format that you want without sacrificing ease of use or speed" - but I want to be able to use the forename only (so, for instance, I can address newsletters with Dear Jacob). It's certainly not about validity / invalidity of names. And yes, that's not a perfect situation - some people may prefer Dear Mr Aldridge or Dear Jake (ugh). But as long as I recognise that shortcoming, and (which I do) only require a single name (so people with only one name are not ruled invalid), I don't see how a unified field gives me the format I want.
- joshfraser 15y agoFor those who are interested, I wrote a post on the challenges of extracting forenames and surnames and shared some imperfect code that takes a stab at it: http://www.onlineaspect.com/2009/08/17/splitting-names/ http://www.onlineaspect.com/2009/08/17/splitting-names/
- InclinedPlane 15y agoEasy peasy. Use a good algorithm that is correct most of the time and present the results to the user in a way that's correctable.