Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
A case of case

Do you have people enter their (postal) addresses on a form on your web site?
Does everyone lay out their address as it should be on the postage label?

If you've answered "yes" to the first question, I'll bet you've answered a resounding "no" to the second. It depends on just what you're selling online (and so on how net-aware your users are), but chances are that many people will supply their addresses all in one line, and that many will be all-capitals or all-lower-case. We've found that (in general) these problems apply to 1 in 5 submissions.

But what to do?

Catch 22.
If you always re-capitalise the first letter of each word only, you upset the daVinci-s and MacDonalds.
If you leave alone, your labels will look unprofessional and some bright spark will tell you that you're rude to use a lower case letter at the start of his name.

The solution that we've come up with over the years is as follows:

Check the address for case (in PHP, ereg("[A-Z].*[a-z]" .... will check for upper followed by lower)
a) if the user has entered it using both upper case and lower case characters, then he/she probably knows what he/she's doing and it should be left alone.
b) if the user has entered it in a single case, force it all to lower case the capitalise the first letter of each word - if you're using PHP, functions strtolower and ucwords will do this for you.

THEN check the address for new line characters
c) If you have at least one new line character between "printables" you can once again assume the user knows what they're doing
d) If you don't have embedded new lines, try replacing "comma-space" sequences with a new line, but not is that leaves just a number on a line on its own!

No solution id 100% user-proof but you should find the above deals with 95% of the rogue entries!
(written 2004-11-14 08:25:31)

 
Associated topics are indexed under
G902 - Well House Consultants - Web site techniques, utility and visibility

Back to
The next generation of programmer
Previous and next
or
Horse's mouth home
Forward to
History around you
Some other Articles
Fair and Simple
Good early morning
PHP course. Come by train.
History around you
A case of case
The next generation of programmer
Expiration dates or times on web pages
Relative or absolute milkman
A Parallel for Perl 6
Avoid the wheel being re-invented by using Perl modules
1916 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho