<validate>

A child tag, used in conjunction with the <input> tag. This child tag is used to validate the input of text boxes. You can choose to only accept numeric input, date input, or input with a specific format as defined by a regular expression pattern.

ATTRIBUTES <validate>:

type

(Required) Specifies the kind of validation that should occur. The possible values for this attribute are:

  • numeric - value entered must evaluate to a numeric value. This could be values consisting only of digits but it may also include commas and decimal points. In short, anything that can be converted to a number (a double, for programmers) is valid.
  • date - the value entered must evaluate to a date. Any value entered that can be converted to a date will be valid.
  • compare - Validates the control against either a hard-coded value (specified in the valuetocompare attribute) or the value of another control (specified in the controltocompare attribute). When using the validation type, you should also specify the operator attribute and you may also want to use the datatype attribute.
    New to version 4.7
  • regexp - Use this type of validation when you need more control over user input. Using regular expressions, you can verify that user input matches the regular expression pattern you specify in the expression attribute.
  • required - When you want to force required field validation to occur on the server rather than client, use this type of validation.
    New to version 3.0

NOTE: The user must enter a value in order for it to be validated. This allows you to keep the field optional, but still validate the input if something is entered. If you want to always validate the field, you should also set the "required" attribute of the <input> tag to true.

(new to version 1.2)

expression

(Required if type="regexp") This attribute is used if the validation type is "regexp". It contains the regular expression pattern that the user's input must match in order to be valid. This attribute is required if the type is "regexp". It is ignored if it is another type. (new to version 1.2)

enableclientscript

Optional. This option is valid only for regular expression validation (as numeric and date validation isn't performed on the client-side). Set this attribute to false to force XMod to perform the validation on the server, rather than the client. By default, this value is true.
(new to version 3.1)

message

(Required) This is the error message that will be displayed if the user's input is invalid. (new to version 1.2)

text

(Optional) When using a <validationsummary> control, you can use this property to display different text to the user near the offending field and the <validationsummary> will use the value of the message property. A typical use would be to set this property to an asterisk (*) and set message to the full error message. The asterisk would give the user a visual cue that the field has an error.
(new to version 3.2)

class

(Optional) The CSS Class to be used to style the error message. (new to version 1.2)

controltovalidate

(Optional) For custom HTML layout forms only, this property allows you to place your validation control wherever you'd like in your form. Normally <validate> tags are placed inside the tag of the control they are validating. At run-time, the validation messages are rendered next to or below the control. With this new property you can move your validation message elsewhere in the form to make it more visible or to fit better with your layout.
(new to version 4.5)

controltocompare

For compare validation only: Specify the ID (i.e. the ref) of the control against whose value you want to compare.
(new to version 4.7)

valuetocompare

For compare validation only: A hard-coded value to use as the basis for comparison.
(new to version 4.7)

operator

For compare validation only: Sets the comparison that will be performed. In the descriptions below, "A" is the value in the control to be validated. "B" is the value that is hard-coded in valuetocompare or the value of the control identified in controltocompare.

 

  • Equal: A is the same as B
  • NotEqual:  A is not the same as B
  • GreaterThan: A is greater than B
  • GreaterThanEqual: A is greater than OR equal to B
  • LessThan: A is less than B
  • LessThanEqual: A is less than OR equal to B
  • DataTypeCheck: A data type comparison of A and the data type specified in the datatype attribute. Validation fails if A cannot be converted to that data type.

(new to version 4.7)

datatype

For compare validation only: Sets the data type the values being compared are converted to before the comparison is made. Also see the operator attribute's DataTypeCheck value. Valid values are:

 

  • String: A string data type (i.e. textual data)
  • Integer: A 32-bit signed integer data type
  • Double: A double-precision floating point data type.
  • Date: A date data type.
  • Currency: A monetary data type.

(new to version 4.7)

 

EXAMPLE

<input ref="txtQuantity" class="NormalTextBox" width="50px">

  <label>Quantity: </label>

  <default>1</default>

  <validate type="numeric" message="You must enter a number for Quantity" class="NormalRed"/>

</input>