- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frost.. err, first.. umm Frist! but does this mean we need a pass code for zippers?
Admin
Wlhat is zippers or ZIP code? Always have been wordering this when coding for clients.
[image]Admin
Validating a ZIP code is one thing, but doing it entirely on the server side? Oh, ow.
(Wouldn't work for UK post codes, where the list is much longer as the form commonly used identifies at the street/sub-street level. They have to be server-validated. OTOH, postcode and house number identifies a mail drop exactly.)
Addendum (2012-03-26 10:19): D'oh! I meant “client side” there. Too much thinking about OpenID and Shibboleth is melting my brain…
Admin
The USPS sends out quarterly updates. The previous programmer clearly subscribed to that, then ran a DB extract to rebuild the very clever Javascript error checking against the allowable zip codes.
Admin
Admin
FTFY
Admin
Yeah, he should have done it entirely on the client side, to save the round trip!
Admin
My other half has family living near each other just one street apart in a town over there and if someone is out of town and a package shows up, the mail carrir knows to just leave it at another family members house. Works out well there.
Admin
If it was data driven we could argue either way, this is after all, the DAily WTF, where we can argue abotu almost anything.
Admin
Herr Otto says, if you live deep enough in the shires, your postie will most likely leave parcels for you outside the door, even if you aren't there to sign for it, as Herr Otto found out on Friday, when he came home from work to find his newly-ordered-to-be-delivered-on-Saturday-for-ten-pound-extra £300 graphics card sitting in a puddle.
Admin
At least with UK post codes you can use a regex to validate most cases. US zip codes are far more troublesome. I am just glad that the guy was not trying to validate zip+4 and delivery point also.
Admin
Admin
The joke is that it's clearly client-side Javascript and that the server has nothing to do with it
Admin
Someone went to the trouble to make it so that you can run javascript serverside (node.js). I don't know why you would want to subject yourself to this kind of pain but its always possible this was done serverside. Except of course for the call to document.getElementById("Zip").value and the display change... but just cause its javascript doesn't lock it to the client.
I give him +1 as well for using the "+" to concat the thousands of strings together instead of the usual / to indicate that we are putting more than 1 line into a string.
Admin
Seen worse. Somebody told him/her to do it, so it was done. Updates become job security and, hopefully, will be script-performed.
Instead of using split, he/she could have added a space before and after all the codes and done an "indexOf" on space+zip+space.
As for sending this all down to be done client-side, that doesn't seem too wise a use of bandwidth, although if it's in a .js file it will be cached.
Admin
Admin
Well duh... we're always carping about the importance of using a whitelist to accept known good entries instead of a blacklist to ban known bad entries. That's obviously what's been done here!
Admin
I remember once time we received a postcard mailed from a friend who was holidaying in Spain. They couldn't recall our address and so it was addressed to "name, town, UK". No house number, street name, or even a postcode. IIRC they didn't even include a full name, just the surname. "Town" at that time was a medium sized town of maybe 30,000 people (and another 80,000 or so in the wide area around it). But a lot of the people who had lived there a generation or more knew each other, from when the town was a good deal smaller.
"Town, UK" got it from Spain to the local sorting office. Someone there figured out which "name" it was for (probably because they knew or at least recognized the person who sent it, and knew they were a family friend) and put it in the load for that mail route. The postman knew which house on the route belonged to "surname" and delivered it successfully.
It probably helps that this was back when customer service was still considered worth bothering with and we had a couple of relatives who worked in the post office.
Admin
TRWTF was you found fault in which side the validation was but not how the validation was performed?
Admin
Do you ever get curious about what your twin might be interested in or can you hear his/her thought telepathically?
Admin
Telepathy doesn't exist, we communicate purely through homeopathy. Yes I can smell my twin half way across the world.
Admin
OK, which one of you has been diluted until the presence of you cannot be detected?
Admin
Admin
This sound exactly like Village in India.
Admin
My ZIP Code is for a "Contract Station" at a University. Until not too long ago, this ZIP Code was NOT included in the USPS data base. Before it was included, I never got junk mail; now that it is, I do.
Admin
I suppose very clever is a matter for debate.
Admin
Clearly the other person. If you could not detect KattMan you wouldn't be talking to him
Admin
The real wtf. If only we lived in a perfect world.
Admin
theres already a space between each, and they're all 5 numbers. so an zipstr.indexOf(Zip) is succificent
Admin
How do you use / to get a multi-line string in JavaScript? The only workarounds that I have ever seen for multi-line strings are rather ugly.
Captcha: decet. Are you deceting me that there exist multi-line strings in Javascript?
Admin
Admin
I was once lived on a Kibbutz for about two years. I had received mail there from across the Atlantic addressed to: Dotan Cohen Sarid, Israel
I thought that must be a record for shortest addressLength:kilometersSent in history. No street, house number, ZIP code, and it still got to where it should be after 5000+ KM. I didn't even know the postwoman at the time.
Admin
Ok lazy. I will educate you. https://www.google.com/search?q=multi+line+strings+in+javascript
And perhaps its a \ not a /. I don't usually use multilines in javascript.
Admin
But I, this code, this place, these people -- our shared experience buoys us in times of strife and shite code.
Admin
I'm still not educated. In fact, you will notice my name in the top google hit for that query. There are no multi-line strings in JavaScript. The backslash concatenates two lines of programming code into a single-line string.
Admin
Admin
Admin
Admin
What, no XML?
Admin
No. There has been no check that the code supplied is actually five characters, or that it contains no spaces. Your version would accept "1" or "1 000" as valid.
Admin
Admin
As someone who has been in a new zip code for almost 5 years, I still run into a lot of sites that still don't work with my zip code.
Admin
Fortunately it only needed to contain common combinations (and alternate spellings), and was a one time static thing (so did not need to be kept up to date).
Admin
Admin
Zip codes are very infrequently added, as they are point-based delivery mechanisms. So I believe it should be OK to maintain a static list of available zip codes.
Admin
Nah - no record. That goes to the letters to Santa :)
Admin
Unless you are in India, in that case, you do not wish to maintain them at all. Post office maintaining them for you.
Admin
Admin
Admin