<Validate type="compare">

The Validate tag whose type is set to "compare" is referred to as a Comparison Validator and is used to ensure the value of the target control is the same as a hard-coded value or the same as the value in a second control. It is useful when prompting the user for an email address or password.

Syntax

<Validate
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge| Inset|Outset"
    BorderWidth="size"
    CompareTarget="string"
    CompareValue="string"
    CssClass="string"
    DataType="String|Integer|Double|Date|Currency"
    Display="Static|Dynamic"
    EnableClientScript="True|False"

    Message="string"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium| Large|X-Large|XX-Large"
    Font-strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    Operator="Equal|NotEqual|GreaterThan|GreaterThanEqual|LessThan|LessThanEqual|DataTypeCheck"
    Target="string"
    Text="string"
    Type="Compare"
    Width="size"

/> 
 

Remarks

When the "type" attribute is set to compare, the control prevents the form from being submitted if its associated control does not match a value - either a hard-coded value or the value in a second control. You associate a control with the <validate> tag by setting its "target" attribute to the ID of the control you wish to validate. To compare the target control with the value of a second control, place the second control's ID in the "comparetarget" attribute and do not define the "comparevalue" attribute. To compare it with a hard-coded value, place that value in the "comparevalue" attribute and do not define the "comparetarget" attribute. If you set the "operator" attribute to DataTypeCheck then choose the datatype to check-for using the "DataType" attribute. The "message" attribute is the text that will be displayed to the user when validation fails. If you are using the <validationsummary> tag, then you can also supply a "text" attribute. When validation fails, the "text" will be displayed where your <validate> tag is and the "message" will be displayed in the <validationsummary>.

Back to top

Example

<addform>
  ...
  <table>
    <tr>
      <td>
        <label for="txtEmailOne" text="Email" />
        <textbox id="txtEmailOne" />
      </td>
      </tr>
      <tr>
        <td>
          <label for="txtEmail" text="Email" />
          <textbox id="txtEmail" datafield="Email" datatype="string" />
          <validate type="compare" target="txtEmail" comparetarget="txtEmailOne" message="The email addresses don't match" />
         </td>
      </tr>
      <tr>
        <td colspan="2">
          <addbutton text="Add"/>&nbsp;<cancelbutton text="Cancel"/>
        </td>
      </tr>
  </table>
</addform>
Back to top