The mgiValidateData Tag
Tag Behavior
Use the mgiValidateData tag to check text for specified formats.
Tag Syntax
The mgiValidateData tag has four types. Each type has different
required and optional parameters. The mgiValidateData types are:
- string - Validates text values.
- integer - Validates integer values.
- real - Validates real number values.
- date - Validates date values
String Type
The string type of mgiValidateData has one required parameter
and four optional parameters. The tag form is:
<mgiValidateData data="Text" type="string" failureURL="URL"
format="Format" regularExpression="RE Value">
Required Parameters:
- data - The data is the text to validate.
Optional Parameters:
- type - The type is the type of information that is
validated. The "string" type validates the format
of a text string. "String" is the default type of the
mgiValidateData tag. If the data does not match the type given
or the data value is empty, then an automatic failure occurs.
- failureURL - The failureURL is the page where failed
validations are redirected. The default behavior is to display
the words "invalid data" if the data does not meet
the specified criteria and to display the data you are validating
if the data does meet the specified criteria.
- format - The format is the pattern that is validated
in the data. The "url" format compares the data
to a URL pattern. The "emailAddress" format
compares the data to an email address pattern. The
"regularExpression format compares the data
with the expression provided in the regularExpression parameter.
There is no default value.
- regularExpression - The regularExpression is the regular
expression pattern validated in the data. Create a regular expression
pattern using regular expression
symbols.
- display - Whether or not the tag should display the result or the
"invalid data" message after being processed. Valid values are "yes"
and "no". The default value is "yes". (Note: This
parameter, if set to "no", should be used in conjunction with the failureURL parameter
to catch invalid data.)
Integer Type
The integer type of mgiValidateData has two required parameter
and four optional parameters. The tag form is:
<mgiValidateData data="Number" type="integer" failureURL="URL"
upperBound="Integer" lowerBound="Integer">
Required Parameters:
- data - The data is the number to validate.
- type - The type is the type of information that is
validated. The "integer" type validates the
format of a whole number.
Optional Parameters:
- failureURL - The failureURL is the page where failed
validations are redirected. The default behavior is to display
the words "invalid data" if the data does not meet
the specified criteria and to display the data you are validating
if the data does meet the specified criteria.
- upperBound - The upperBound is the maximum value of
the data.
- lowerBound - The lowerBound is the minimum value of
the data.
- display - Whether or not the tag should display the result or the
"invalid data" message after being processed. Valid values are "yes"
and "no". The default value is "yes". (Note: This
parameter, if set to "no", should be used in conjunction with the failureURL parameter
to catch invalid data.)
Real Type
The real type of mgiValidateData has two required parameter
and four optional parameters. The tag form is:
<mgiValidateData data="Number" type="real" failureURL="URL"
upperBound="Number" lowerBound="Number">
Required Parameters:
- data - The data is the number to validate.
- type - The type is the type of information that is
validated. The "real" type validates the format
of a real number (positive or negative with decimals).
Optional Parameters:
- failureURL - The failureURL is the page where failed
validations are redirected. The default behavior is to display
the words "invalid data" if the data does not meet
the specified criteria and to display the data you are validating
if the data does meet the specified criteria.
- upperBound - The upperBound is the maximum value of
the data.
- lowerBound - The lowerBound is the minimum value of
the data.
- display - Whether or not the tag should display the result or the
"invalid data" message after being processed. Valid values are "yes"
and "no". The default value is "yes". (Note: This
parameter, if set to "no", should be used in conjunction with the failureURL parameter
to catch invalid data.)
Date Type
The date type of mgiValidateData has two required parameter
and eight optional parameters. The tag form is:
<mgiValidateData data="Date" type="date" failureURL="URL"
upperBound="Date" lowerBound="Date" upperSpan="Integer"
lowerSpan="Integer"
dateFormat="Format">
Required Parameters:
- data - The data is the date to validate.
- type - The type is the type of information that is
validated. The "date" type validates the format
of a date.
Optional Parameters:
- failureURL - The failureURL is the page where failed
validations are redirected. The default behavior is to display
the words "invalid data" if the data does not meet
the specified criteria and to display the data you are validating
if the data does meet the specified criteria.
- upperBound - The upperBound is the maximum date of
the data. The upperBound date must be in the form mm-dd-yyyy
unless specified otherwise in the dateFormat parameter.
- lowerBound - The lowerBound is the minimum date of
the data. The lowerBound date must be in the form mm-dd-yyyy
unless specified otherwise in the dateFormat parameter.
- upperSpan - The upperSpan is the number of days after
the current date when the data is valid. The upperSpan value
must be a positive integer.
- lowerSpan - The lowerSpan is the number of days before
the current date when the data is valid. The lowerSpan value
must be a positive integer.
- dateFormat - The dateFormat is the required format
of the data. Valid values of the dateFormat parameter are "mm-dd-yyyy"
and "dd-mm-yyyy". The default value is "mm-dd-yyyy".
- delimiter - The delimiter that must separate the month, day,
and year values. If no delimiter is specified, dashes('-'), back slashes('/'), and periods('.') will
be accepted as valid delimiters.
- display - Whether or not the tag should display the result or the
"invalid data" message after being processed. Valid values are "yes"
and "no". The default value is "yes". (Note: This
parameter, if set to "no", should be used in conjunction with the failureURL parameter
to catch invalid data.)
Example Usage and Output
String Type
<mgiValidateData data={mgiPostArgument name="Email"}
type="string" failureURL="emailerror.mgi" format="emailAddress">
In this example, an email address from a form submission is
verified. If the "Email" field is left empty or if
the email address is not formatted properly, then the visitor
is redirected to the emailerror.mgi page.
Integer Type
<mgiValidateData data={mgiPostArgument name="Quantity"}
type="integer" failureURL="quantityerror.mgi" lowerBound="1">
In this example, the quantity of a product is verified. The
quantity must be a whole number greater than 1, otherwise the
visitor is redirected to the quantityerror.mgi page.
Real Type
<mgiValidateData data={mgiPostArgument name="Price"} type="real"
failureURL="searcherror.mgi" upperBound="1000000.00">
In this example, search criteria for the price of new homes
is verified. The entered price must be a real number less than
1 million dollars, otherwise the visitor is redirected to the
searcherror.mgi page.
Date Type
<mgiValidateData data={mgiGet name="Appointment Date"}
type="date" failureURL="daterror.mgi" upperSpan="5">
In this example, an appointment date is verified. The appointment
date must be anywhere from the current date to five days after
the current date, otherwise the visitor is redirected to the
dateerror.mgi page.
Suggested Usage
- Form Processing
- Identification Verification
|