Those wacky users can type almost anything into a form, so you’ll want to make sure that if they entered anything into the Zip code field (Figure 7.11) that it contains only numbers. Script 7.14 shows you how.
To make sure Zip codes are valid:
✓ Tips
If at some later point we wanted to add a new field to the HTML form that had to be numeric, no new JavaScript code would need to be written. Instead, we’d just use the now-existing isNum check.
Remember, it’s the World Wide Web, not the American Web. If your site is likely to draw attention from outside the United States, don’t require that the user enter a Zip code. Addresses outside the United States may or may not have postal codes, and those postal codes may not be numeric.
3.21.43.192