News for hackers. Stuff that matters.
Re:Put the zip code first by avidiax on Saturday March 07, 2026 @06:54PM (#47292730)
Should be titled "Put the Zipcode and country first".

Would be simple enough to have someone type the zip or postal code first, then move the countries that are known to have that zip code to the top of the drop down (still in alphabetical order), and all the other countries below that (also in alphabetical order).

Leave all the fields editable, i.e. the postal code only suggests, ranks, or prepopulates.

Seems like that would handle all the edge cases, including those where a zip code doesn't refer to one and only one city, or where a zip code has changed or been added to a country.

Re:Put the zip code first by notpushkin on Saturday March 07, 2026 @07:24PM (#47292969)
Yeah. But also, are you ready to maintain a postcode to city mapping for every country you have a significant userbase in?
Re:Put the zip code first by avidiax on Sunday March 08, 2026 @04:23AM (#47295591)
I'm definitely not, but the lazy method is just to cache the data your customers provide, or curate some data for the countries you are most interested in.

That gets around countries that consider their postal code database a licensed dataset.

Re:Put the zip code first by notpushkin on Monday March 09, 2026 @12:07AM (#47304795)
That’s a clever way of doing it, yeah.

From UI side, I’d probably not autofill, but add autocomplete (e.g. using <datalist>¹). This way you can still have browser autofill the user’s address if saved (do also set the autocomplete² props correctly!), and suggest one or multiple variants you have in your database, and let the user fill it out manually still, without having to find and click “My address isn’t here”.

¹<datalist>: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...

(quick note re: compat; Firefox does support it for the text fields, check the table at the bottom)

²autocomplete: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...

Re:Put the zip code first by peyton on Saturday March 07, 2026 @07:10PM (#47292860)
ZIP Code (tm) is claimed as a trademark by the US Postal Service. If you don’t have a ZIP Code, why would you put something in the ZIP Code field?
Re:Put the zip code first by rmunn on Saturday March 07, 2026 @07:15PM (#47292900)
Because most websites won't have two separate fields for "ZIP code" and "postal code". Even if they knew that ZIP Code is a trademark (I didn't until you mentioned it), they would (wisely) know that putting in two fields would just confuse most people. So they put in one field. Many sites label it as "ZIP code / postal code", but some just label it as "ZIP code". But the intent is clear: put in the multi-digit string that identifies your address, whether your country calls it a ZIP code or a postal code.
Re:Put the zip code first by pstuart on Saturday March 07, 2026 @07:16PM (#47292913)
Put a postal code first.

Include a field for the country that is autofilled via Geolocation API or geoip if that's unavailable.

Re:Put the zip code first by notpushkin on Saturday March 07, 2026 @07:27PM (#47292999)
Put country first. Postcode doesn’t make sense without one. Prepopulating one based on location is generally okay, but don’t assume it will always be the same.

Or just don’t try to be too clever.