Need help?
<- Back

Comments (230)

  • modeless
    > From those 5 characters you can determine the city, the state, and the countryFalse. Many zip codes include more than one city, and some even cross multiple states. And you can't always tell the difference between codes from different countries. Now you're not just instantly filling the rest of the form, you're implementing fancy multi-country filtering logic, editable drop downs, etc. Given the obvious incompetence of the people implementing most web forms, you're asking for disaster here.Instead, learn to use your browser's autofill feature, and design your sites with it in mind. If you do it right the user literally doesn't have to type a single character. That's even better than typing a numeric code. Sadly even this seems beyond the abilities of the people who implement web forms.
  • loloquwowndueo
    US-centric. I typed a Mexico postal code (it’s five digits) and got routed to somewhere in Maine. So - yeah the whole “I can tell you’re in the US just by the zip code” premise is entirely flawed.
  • stavros
    So I typed my zip code and got Winsconsin, and couldn't change the country to Greece, which is what my zip code actually is for.Proposing UX improvements is great, but please don't forget the other 95% of the planet.
  • efitz
    Im reading through all these comments and it amazes me how the perfect is the enemy of the good, for many computer people.Ofc there are edge cases. So since there exist a handful of edge cases where a zip code maps to two states, or the more frequent (but irrelevant in the US) case of two or more city names per zip code, we should make everyone suffer?Ofc if you are making a web form you should ask for the zip code first, and auto complete state and city. Let the user edit them if they don’t like what you chose. Or do as some have suggested here and present the official USPS data as a drop down of 2 states or 2-3 cities; thats way better than having to type all of it.And I curse everyone who thinks it’s a good idea to break zip code or phone number or OTP into multiple fields, or if you’re too lazy to set the input type to number.
  • zettabomb
    I fail to see how you can claim this to work for sites which serve areas outside the United States, but have either no ZIP code, an overlapping code, or something else entirely. Germany has 5 digit PLZs, but putting some valid ones in doesn't get a result. It really seems like the author does not think about other countries.I don't disagree with reordering the entry by relevance, but you have to start with country. That can also be a nice search - it will be a very short lookup, even if you put every country name in every language. Only after that is postal code (of whatever kind - it's only ZIP in the US) relevant.
  • sph
    Falsehoods US programmers believe about addresses: there are no other countries than the US of A, and if there are, they don’t really matter.This person bought a whole domain for something that doesn’t work for 90% of the world, claiming it does, never even testing their assumption. Great job!
  • diath
    Ok but that only fetches the codes from the US, so now a non-US resident will start with their zip code and end up with random ass place on the other side of the globe. Now not only I still have to fill in the fields, but also clear them first.
  • mikehall314
    It’s easy enough to say “put the zip first because that will tell you city, state and country in one input”.What happens to customers not in the United States? They have no zip to enter. Or if they have a postal code of some stripe, it has a different format.What about folks who are in Turkmenistan, that you’re grumpy about having to scroll past? How are they signing up?
  • anon
    undefined
  • goloroden
    I entered my zip code… well, wrong country: I’m living in Germany.And even if you knew that, the only thing you could have known from the zip code is the city. At least roughly, because multiple small villages share one zip code.Or, to cut it short: This doesn’t work at all on a general and global level, so I guess there’s a reason why websites do this differently…
  • YokoZar
    The author complains about country selector drop-downs as part of the address flow, but if you're collecting zip codes you are already assuming United States. I don't think there's a country-inferer from completely generic postal code tool out there yet, is there?
  • mttjj
    I definitely agree in principle. But - without doxxing myself - I input my zip and the city is not correct. It’s a very close neighboring suburb (where the boundaries are definitely blurry) but it’s not the city on all the legal documents for my current house.
  • pdpi
    In the UK, it's pretty common for the post code to be the first field in address forms, and for the form to then offer auto-completion for the whole address based on the post code. Postcodes are specific enough that the autocomplete will just give you a handful of addresses (e.g. my postcode will give you just the flats for the building I live in).
  • bichiliad
    Besides the technical constraints (the zip code can't always tell you the city, etc), the zip code is more of a checksum to make sure the address you typed makes sense. I think you could probably get around the imperfections by making the city / state / zip be things suggested to you, whether in an autocomplete or by making them first in a dropdown. The imperfection of a zip code in encoding a city name doesn't mean that the frustration of filling out addresses isn't a real one!
  • tokyobreakfast
    It's impressive someone went to the trouble of putting together this angry dreck, and completely ignoring the fact that ZIP codes often span multiple cities/towns, which not only completely invalidates the author's premise, it would populate the fields with wrong information that would have to be manually corrected later.
  • billforsternz
    It's very interesting how the "you know the city, the state, the country" mantra here is really "you know the city, the state and obviously the country is the USA no other possibilities are considered or worth considering"
  • djoldman
    Fun facts:There are zip codes that map to more than one city.There are zip codes that map to more than one state. (42223)
  • sghaz
    The ZIP-first approach assumes a postal code can deterministically resolve the rest of the address, which is rarely true in practice since many codes map to multiple cities or large geographic areas. Making it reliable requires maintaining comprehensive, frequently updated postal datasets or integrating with external geocoding services, which introduces non-trivial operational complexity. Additionally, deviating from standard address field ordering can work against established user expectations and may degrade usability rather than improve it.
  • hysan
    IMO, the spirit of the idea is to put higher information density fields first, and let that smooth out the UX for the remaining fields as you go downwards. Yes, there will be exceptions but that only matters if you’re trying to absolve the user of all work for 100% of situations. Trying to do that is a fools errand. Invert the order and use the information gathered to make inputting the rest simpler for 80% of the users. Then make it easy for the other 20% to course correct (ex: don’t disable autofilled fields, highlight all text when tabbing to the next field, etc). I think this pattern is a good one to keep in mind, but not blindly follow, when designing the UX of a UI.
  • estebarb
    I tried to put my postal code and it wrongly assumed that I live in the United States.The zip first suggestion seems that would be really inconvenient for around 95.8% of the world population.
  • loloquwowndueo
    I like how instead of just rephrasing the website’s premise to make it clear he only cares about the US, he added some ip-based geolocation to select a snarky response based on where you are. Essentially the site argues back to you if you’re not in the US or something. Why did this person even bother creating the website if he’s so hostile and angry.
  • apendleton
    Zipcodes are not great for reliably describing locations. They're collections of multiple postal delivery routes, and that's it. There's no guarantee that any given zipcode lies within a single city, or a single state, or that it lies within the boundaries of the US at all, or that it's contiguous, or that it's stationary (there are some for boats), or that any given location only has one, etc., etc. People think this is a good idea because their particular case happens to work well, but zip codes are rife with edge cases.
  • rishikeshs
    I’m reading this from UAE where zipcodes don’t exist. I wanted to make a similar post so that when you select UAE as country remove the zip code field. Usually the workaround is to type 000000
  • vscode-rest
    I wonder if people had a similarly negative reaction when someone first proposed speculative execution in processor pipelines.“This is is a terrible idea, you’re telling me you will make 99% of cases way faster but completely ignore the 1% that will be slightly slower? Unbelievable.”If you have SA that most of your customers are in USA, this is a good idea. If not, maybe use your brain a bit and figure out if it can be adapted to something which will work for your customer base.
  • pentagrama
    Besides the issues of the OP approach that many point out on this thread, I also want to point out that the ZIP code input on the example, doesn't have the type=number so my mobile keyboard opens with the whole keys instead of the numeric keyboard, in this case that ZIP codes are only numbers, the type=number will improve accessibility.
  • DHPersonal
    Address entries are the weirdest places of frustration. Business clients want Google Places to make address input easier. This user wants a single ZIP code entry to begin the process. Why is adding one’s own address manually that huge of a hurdle that we have to separate the user from the inputs? If there is one person in the world who should know my address, it’s me: why then put such an effort into building a site that takes away my ability to enter my address?
  • fsckboy
    there should be one text box with multiple lines and you enter your address the way you would write it on an envelope. works internationally, gets stuff delivered. If the postal service can parse it, so can a website. Typing in your address will go so much faster than having to read the tags and navigate for every piece they are asking for. any redundancy can be used for error checking which is a good idea.the "fields", like the goggles, they do nothing
  • chrysoprace
    As others have pointed out this is just US-centric, and doesn't work for most countries. The best option I can see is to have an autocomplete, and allow manual addresses with a country-specific form based on a country selection (or detection).
  • twodave
    Most sites I use auto-fill city, state and zip once I type the street address, which is the 1 piece of my address that can’t be guessed from any of the others. So I’d say that’s probably the optimal path for most people, at least in the US. I’m sure people from other countries scoff at the US address suggestion and go straight for the country box from the beginning.
  • teiferer
    I live in 10115. No, not New York. It's Berlin, Germany.I used to live in M6C1B5. By forcing "numeric" on the zip code field, you'd immediately loose all Canadians.This article is so US centric it's not even funny.
  • zeehio
    It should be at least "Put country first, then ask for zip code".08036 Barcelona, Barcelona, Spain08036 Hainesport, New Jersey, USAIt does make some sense to go from most general (country) to more specific (address) instead of the opposite, so the form can implement better auto completions.However in practice postal addresses are not that clean so simple dumb forms are usually better, because it's easy for exceptions to be missed by auto completion algorithms. I would be very pissed if I had to type the zip code above and then correct the wrong guess on every website.Either you are helpful and guess correctly or you don't guess at all.
  • anon
    undefined
  • phippsytech
    This sound like it's more efficient - however... (and ignoring the US specific stuff)Even in forms where I've designed this it breaks my flow as a user. I'm used to suburb state postcode order (I'm an Aussie). It's how we were taught to write the address in school. It's been a pattern for a long time, and the reversal of the fields slows my brain down.IMHO The better user experience isn't changing the order of the fields. It's honouring auto-complete so the user doesn't have to enter this data in the first place.
  • RASBR89
    In the last couple of years in the uk, address forms ask for you street address and the rest will autocomplete from there - city, postcode. Makes things a lot easier in the way the author suggests
  • c0balt
    Awesome idea, IF you are US only and don't cover edge cases and (want to depend on an external API or want to have some sort of eventually outdated map of city <> postcode).It is possible to do this properly, e. G., DHL and UPS do a somewhat okay job of it but isn't easy.
  • dasil003
    When you create a site with a tone this self-righteous and condescending, you should really double check your thinking to make sure there is not some glaring flaw invalidating the premise for the majority of people in the world:> A US ZIP code is 5 characters. From those 5 characters you can determine the city, the state, and the country. That's 3 fields. Autofilled. From one input.I guess this is par for the course in Trump's America, but I still feel embarrassed for the creator.
  • jdlyga
    Zip codes do not have a one to one relationship to cities in the US. It's a common misconception. It's true about 90% of the time, but there are a lot of outliers. I used to work with GIS data and there are a ton of exceptions.
  • justaboutanyone
    This failed when I put in an australian postal code.
  • lsaferite
    Unfortunately you still need country first. But past that, the point stands well. You'll need to adjust the form based on the country, obviously.For the US you can use zip-5 to prefill bunch of data and zip+4 practically fills it all out for a lot of addresses.Each country has some particular nuance though, so it's only as simple as "zip first" or "postcode first" in some locations.
  • lejalv
    Why don't we learn and use our (short) plus code?That would have all the desired properties and then some, and would work everywhere on Earth.https://en.wikipedia.org/wiki/Open_Location_Code
  • cranky908canuck
    Agreed, but:JRandomCustomer enters street-number, apt-number, city, state, code ... in that order.Also, many websites seem to have a negotiation with the browser, where, given: a street address, -> they can populate the other fields.Definitely not perfect
  • kawsper
    My postal code is 2200 (København N), and that form didn't do anything for me.All zip codes are postal codes, but not all postal codes are zip codes.At my last gig, this sentence was said a lot, and people kept confusing the two, both in code and in daily speech, so maybe colloquially they are the same :)
  • evrimoztamur
    In the Netherlands most websites use a common routing database to map a combination of a ZIP code and house number (+ suffix) to your exact address automatically. Great UX! And naturally depends on good administrative and postal services data quality.
  • dgeiser13
    Some zip codes cover multiple cities.
  • LeoPanthera
    Why do we not use ZIP+4 add-on codes anymore? Some sites won't even accept them. If you put that in first, you've narrowed it down to one street at worst, in most cases.
  • kube-system
    > You didn't need me to scroll past Turkmenistan.You’d absolutely have to determine that you’re in the US before asking for zip code.
  • muppetman
    The ignorance of this post to the rest of the world is amazing.
  • anon
    undefined
  • conductr
    I know some zips covers multiple cities. I would imagine some cross state lines in places too. Doesn’t cover multiple countries either as some have similar formats (5 digits). So there are edge cases that make this infeasible
  • tomjakubowski
    Use ZIP Code: the last word in mail address.
  • smallnix
    The visit Japan website for faster customs clearing does that. Zip first with auto fill. Very nice: https://www.vjw.digital.go.jp
  • senadir
    The kind of takes that promote the stereotypes of self-centered americans.
  • altairprime
    “A postal code will belong to a single city” applies: https://news.ycombinator.com/item?id=8907301
  • aed
    > If you're asking for a ZIP code, use inputmode="numeric"Does this work for zips? Some zips have a leading 0.
  • fjfaase
    The Dutch zipcode and the house number are unique. So, to mail something to the Netherlands anywhere from the world, it is enough to write something like: NL 1072CT 4.
  • petee
    My zip covers two cities, each has a similar street name; 5-digits isn't enough.I've encountered websites that take the zip and won't let me change the wrongly-assumed city
  • slartibardfast0
    This works really well in Ireland. Eircodes (our late adoption postal codes) resolve to individual addresses rather than areas, so Irish sites mostly do this.
  • 1970-01-01
    Go with 20252 when you know they're just collecting it to send junk mail. Many programmers don't even try to filter for it.
  • zackify
    I only ask for zip on our checkout. And get the email from one tap methods.Like the author I cannot stand how stupid some checkout processes are!
  • WBrentWilliams
    Ehh... US-centric. Better to use significance order: Country, then postal (most countries have postal), then region, city, and street address. Best, however, is to _not_ separate the address into fields. Instead, allow a free text field for the person doing data entry to put in the address in _their_ format and then parse it on the backend. This gets you the most flexibility and allows you to encounter and handle corner cases by using (my favorite test data) public addresses from all over the world. _I_ routinely test my address entry by Googling McDonald's locations and feeding them into my system. Handle an inscrutable address like any other bad data and say, politely, that your system does not understand the data.All that said, free-form entry is a hard sell. My _customers_ expect field data entry, so I implement field data entry. I just re-order my checks to be more forgiving until the data entry is complete.I was implementing a customer service address entry using significance order 25 years ago. As I already _knew_ that I had a US-centric customer base (we sold long distance to sorority and fraternity members), entering US ZIP first saved a lot of time and more highly leveraged the US postal address cleaner that we had already purchased for our mass marketing mailers. The people working the call center _loved_ it, as they could focus more on their call turn-over than on data entry.
  • sib
    ZIP codes don't uniquely identify cities / towns. (Or, in fact, States). Not to mention, they certainly don't work globally...
  • loloquwowndueo
    Le sigh. It has now a disclaimer at the top. “Hello from across the pond (or whichever body of water separates us). This is a US ZIP code website. We are aware that other countries exist.”This guy just keeps digging himself into a hole of ignorance - is he aware of Mexico? Canada?
  • throwaway0665
    It doesn't take long to type your address. Plus password managers or keyboards often auto fill it. It's not that deep.
  • tokyobreakfast
    The US Postal service has some of the most complex software in existence, including some of the most advanced handwriting recognition ever developed.The fact that mail gets to its destination when it does, as soon as it does, with overall minimal error, is nothing short of amazing.But some web dev blogger has it All. Figured. Out.Right.I'm sure your way is better.This is big "I could code it in a weekend" HN energy.The USPS owes you a debt of gratitude for buying a snarky domain and bringing this to their attention after 63 years.
  • jmull
    Autofill seems like a better solution.
  • agnishom
    Somehow a lot of Japanese websites use this trick. Far more often than USian websites.
  • talkvoix
    I completely agree with the premise, but if we just ask for the ZIP code first and auto-fill the rest, how am I going to justify my 2-week sprint to build a custom, React-based, fuzzy-searchable, virtualized dropdown component for the 'State' field?Just kidding xP
  • paulddraper
    Flawed premise.This works within a country, but not between countries.For example 77520 is the zip code of Cancun, Mexico and Baytown, Texas.---Needs to be country + zip code (postal code).
  • morganf
    Someone needs to write "Falsehoods programmers believe about zip codes" hahahaha ;)PD: if you don't get the reference, a classic: https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-...
  • fenwick67
    Galaxy brain: address should just be a multi-line field
  • joshellington
    I wish I could downvote this. Please don’t do this folks. Editing “guessed” filled inputs when they’re incorrect is a higher UX bar of effort than browser autofill or even just typing it (especially on mobile). Plus a non-zero number of users will just not correct or be confused and abandon.
  • aleph_minus_one
    I guess a better proposal would be:- Put the country first- Put the zip code second
  • exmadscientist
    Related, on the country drop-down front: please put the United States (or whatever your customers' main country is) at the top. You can probably tell I want the US from a combination of, you know, 99% of your sales being to the US and my language being set to English. And, sure, put Canada and even the UK next to it. Go wild, have the top ten English-speaking countries there if you like! It makes things so much easier.The trick, then, is that you don't remove anything from the alphabetical list. With modern computer technology, we can have two places to find something! So if I miss your fancy shortcut, or it's not applicable to me, everything will still be in the regular old familiar place. It just works.
  • pbnjay
    Um a lot of US zip codes map to multiple cities. Some even to multiple states. If you build a picker for city/state this works fine but your premise is easily refuted if you look at the data!Zip codes map to postal routes, not polygons
  • krater23
    Maybe first start with using non subhuman units like meter and celsius, then learn that there are other countries than 'The United States of America' and then fix that with the zip codes. ;Pp.s.: Don't takt this too serious, have just a dark kind of humor.
  • junon
    "See how you typed 5 numbers and three fields filled themselves in?"Nope! Didn't see that. Seems the zip code registry doesn't have a number of German zip codes.
  • hluska
    In a similar tone, it’s 2026. Why are we still messing with form ordering instead of leaning into autofill? So somehow it makes more sense to change every single address form in existence to a non standard order because…why exactly? There’s a whole world outside of the United States with many formats for postal codes. It’s more efficient to just use autofill…
  • angrydev
    Autofill
  • hirvi74
    While interesting, it would take me more time to implement and validate this logic than it would take the user to enter the data.
  • anon
    undefined
  • enraged_camel
    I would say this doesn't actually work well for UX, because people are more likely to know their street address and city than their zip code. Personally, every time I've moved over the years, it took a few weeks for me to internalize my new zip code.
  • hettygreen
    Americaaaa.. fuck ya!
  • nomdep
    If you’re going to ask for a country, ask for it first.Zip codes repeat across countries, you know.
  • jiveturkey
    ratio'd
  • jshchnz
    preach
  • rezmoss
    [dead]
  • samtregar3
    [dead]
  • xorgun
    [dead]