Compare constraints - Demonstration

In the following demonstration, even fields are compared to the preceding fields.

  • The second field should have a greater date than the first field.
  • The fourth field should have a smaller double than the third field.
  • The sixth field should have a greater or equal amount of mney than the fifth field.
  • The eighth field should have an equal text to the seventh field.
 
Compare Constraint Example
Some Date
Greater Date
Some Double
Smaller Double
Some Amount Of Money
Greater Or Equal Amount Of Money
Some Text
Equal Text
XML output

        
Compare constraints - Description

The compare constraint provides the functionality of the ASP.NET Compare Validator to the MForm items.

The compare constraint allows comparing the item's value to a fixed value or to a value of a different MForm item.

The compare constraint control has the following properties:

  • Type - the comparison data type, an analogue of the CompareValidator.Type property
  • ValueToCompare - a fixed value the item is to be compared to, an analogue of the CompareValiator.ValueToCompare property.
  • ItemToComparePath - an xpath-like path to the item, whose value will be used for comparison (if both the ValueToCompare property and the ItemToComparePath property are set, the latter takes precedence)
  • Operator - the comparison operator: equal, not equal, greater than, greater than or equal, less than, less than or equal; an analogue of the CompareValidator.Operator property

The compare constraint performs the validation by invoking both client and server side CompareValidator's validation methods. Thereby the behavior of this constraint should maximally resemble the behavior of the CompareValidator.

This page is hosted free, courtesy of GoDaddy.com®
Copyright © 2009 GoDaddy.com, Inc. All Rights Reserved.
Domain names from $1.99
Visit GoDaddy.com for the best values on: Domain names, Web hosting and more! See product catalog.