JRS: In article <ev**********************@newsread2.prod.itd.earth link.
net>, seen in news:comp.lang.javascript, Patrick Gibbons
<fn******@hotmail.com> posted at Sun, 27 Jul 2003 18:04:58 :-
I would like to know what keycode # pertains to what keycode . . .
This code allows a user to limit the entries in a form to only those
keycodes they would like, #s only for US zip codes, for example.
Most users, on being asked to enter a valid postal code, will enter a
valid postal code; or at least one which is grammatically sound.
I see little point in forcing them to download all the code which is
necessary to scrutinise the individual keystrokes, when it is easier to
validate the code on loss-of-focus or completion-of-data.
Completed postal codes can be checked, quite economically, by using a
well-chosen RegExp; a liberal check for world-wide codes, a rigorous
format check for Canadian ones, a choice for UK ones, etc.
Will
OK = /^[a-zA-Z0-9- ]{m,n}$/.test(PoCo)
or a little more, match all world postcodes, after whitespace
normalisation ? What are the proper m & n ?
Please contact me if you have any questions,
QHAH. FAQ 2.3, 2.4.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c. FAQ items, acronyms