Perl Form Builder ::Features ::Download ::Tutorial ::Examples
::Documentation ::FormBuilder Google Group ::Old List Archives ::Contribute
Note: The mailing list is has been replaced by the Google FormBuilder Group

Built-In Validation Patterns

FormBuilder has a huge number of built-in regular expressions you can use with the validate option:
Tag Description
VALUE is any type of non-null value
WORD is a word (\w+)
NAME matches [a-zA-Z] only
FNAME person's first name, like "Jim" or "Joe-Bob"
LNAME person's last name, like "Smith" or "King, Jr."
NUM number, decimal or integer
INT integer
FLOAT floating-point number
PHONE phone number in form "123-456-7890" or "(123) 456-7890"
INTPHONE international phone number in form "+prefix local-number"
EMAIL email addr in form "name@host.domain"
CARD credit card, including Amex, with or without -'s
DATE date in format MM/DD/YYYY or DD/MM/YYYY
MMYY date in format MM/YY or MMYY
MMYYYY date in format MM/YYYY or MMYYYY
CCMM strict checking for valid credit card 2-digit month ([0-9]|1[012])
CCYY valid credit card 2-digit year
ZIPCODE US postal code in format 12345 or 12345-6789
STATE valid two-letter state in all uppercase
IPV4 valid IPv4 address
NETMASK valid IPv4 netmask
FILE UNIX format filename (/usr/bin)
WINFILE Windows format filename (C:\windows\system)
MACFILE MacOS format filename (folder:subfolder:subfolder)
HOST valid hostname (some-name)
DOMAIN valid domainname (www.i-love-bacon.com)
ETHER valid ethernet address using either : or . as separators
To make use of any of these, just specify them along with the corresponding field name in the validate option to new():
$form = CGI::FormBuilder->new(
             fields => \@fields,
             validate => {
                first_name  => 'FNAME',
                last_name   => 'LNAME',
                email       => 'EMAIL',
                phone       => 'PHONE',
                card_type   => 'NAME',
                card_number => 'CARD',
                exp_date    => 'MMYY',
             }
        );

FormBuilder is © Nate Wiger, with contributions from many people.
Nateware