The mgiCheckField Tag

Tag Behavior

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.


Tag Syntax

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" 
regularExpression="Pattern">

Required Parameters:

  • name="Field Name" where "Field Name" is the name of the form field to be verified.

Optional Parameters:

  • 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 text@text.text. While it does check for proper formatting, the isEmail parameter cannot check the legitimacy of email usernames or domain names.
  • 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" 
failureURL="emailerror.html">

In this example, the email address field is required and it must bein the format text@text.com. If the email is missing or is not formatted correctly, the "emailerror.html" page is displayed.

Using Regular Expressions

Symbol Functions

\ 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.

[xyz]

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])

[^xyz]

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)


Suggested Usage

  • Form Processing
  • Guestbook
  • Database Submission


[Return to the Referencing MGI Menu]


[User Guide Main Menu] [Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]