5.2.tgz ...
Starting to download Validate_US-0.5.2.tgz (6,578 bytes)
.....done: 6,578 bytes
install ok: channel://pear.php.net/Validate_US-0.5.2
CHAPTER 9 ?– S TRINGS AND REGULAR EXPRESS IONS 275
Note that because Validate_US is a beta release (at the time of this writing), you
need to pass the -f option to the install command in order to force installation.
Using Validate_US
The Validate_US package is extremely easy to use; simply instantiate the Validate_US()
class and call the appropriate validation method. In total there are seven methods,
four of which are relevant to this discussion:
phoneNumber(): Validates a phone number, returning TRUE on success, and
FALSE otherwise. It accepts phone numbers in a variety of formats, including
xxx xxx-xxxx, (xxx) xxx-xxxx, and similar combinations without dashes, parentheses,
or spaces. For example, (614)999-9999, 6149999999, and (614)9999999 are
all valid, whereas (6149999999, 614-999-9999, and 614999 are not.
postalCode(): Validates a ZIP code, returning TRUE on success, and FALSE otherwise.
It accepts ZIP codes in a variety of formats, including xxxxx, xxxxxxxxx,
xxxxx-xxxx, and similar combinations without the dash. For example, 43210 and
43210-0362 are both valid, whereas 4321 and 4321009999 are not.
region(): Validates a state abbreviation, returning TRUE on success, and FALSE otherwise.
It accepts two-letter state abbreviations as supported by the U.
Pages:
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350