The mgiCheckField Tag
The mgiCheckField tag verifies that information has been entered
into a form field (and in a specific format for email addresses).
If the field is left blank or if the isEmail parameter is set
to "yes" and the email address is not in the correct
format, an error page is displayed.
The mgiCheckField tag has one required parameter and three
optional parameter. The tag form is:
<mgiCheckField name="Field Name" isEmail="Yes/No" failureURL="File Path"
- name="Field Name" where "Field Name"
is the name of the form field to be verified.
- isEmail="Yes" or "No" where "Yes"
indicates that the field you wish to verify should contain a
properly formatted email address. "No" indicates that
the field you wish to verify does not have to contain a properly
formatted email address. The default is "No". When
this parameter is set to "Yes", the mgiCheckField tag
will verify that information is present in the form field and
that the information is in the format email@example.com. While it
does check for proper formatting, the isEmail parameter
cannot check the legitimacy of email usernames or domain
- failureURL="File Path" where "File
Path" is the relative URL to the file that is displayed
when a field is left blank or the format of an email field is
not in the correct format. If the failureURL parameter is not
included, a standard MGI error page is displayed.
- regularExpression="Pattern" where "Pattern"
is the comparison string for the information in a form field.
Regular expression special characters such as asterisks (*),
question marks (?), periods (.), carets (^), plus signs (+),
backslashes (\) and brackets [ ] are used to specify the pattern
in form field information. If the pattern does not exist in the
form field information, then an error page is displayed. See
regular expression examples below.
Example Usage and Output
<mgiCheckField name="Credit Card Number" isEmail="No">
In this example, the mgiCheckField tag will verify that a
web site visitor has entered information into the "Credit
Card Number" field.
<mgiCheckField name="EmailAddress" isEmail="Yes"
In this example, the email address field is required and it
must bein the format firstname.lastname@example.org. If the email is missing or
is not formatted correctly, the "emailerror.html" page
Using Regular Expressions
\ Marks the next character as a special character.
"\n" matches a newline
"\r" matches a carriage return (MacOS linefeed)
"\v" matches a vertical tab
"\f" matches a form feed
^ Matches/anchors the beginning of line.
$ Matches/anchors the end of line.
? Matches the preceding character (pattern) one or zero times.
* Matches the preceding character (pattern) zero or more times.
+ Matches the preceding character (pattern) one or more times.
. Matches any single character except a newline character.
A character set (or pattern). Matches any characters between
brackets. Characters can be listed individually (ex. [aeiou])
or in ranges (ex. [e-p] [0-9])
A negative character set (or pattern). Matches any characters
NOT between brackets.
Regular Expression Examples
m.n matches "man", "men", "min" but not "moon".
Te+st matches "test", "teest", "teeeest" etc. BUT NOT "tst".
Te*st matches "test", "teest", "teeeest" etc. AND "tst".
Te?st matches "test", "tst" BUT NOT "teest"
[aeiou] matches every lowercase vowel
[,.?] matches a literal ",", "." or "?".
[0-9, a-z] matches any digit, or lowercase letter
[^0-9] matches any character except a digit
(^ means NOT the following)
- Form Processing
- Database Submission