Form Validation Toolkit

Validation Types

How many different ways or types of validation can we carry out.

Custom Expression Validation

Whether a field is required or not, a field can be checked against a number of custom expressions. If a field is not required, the custom expression validation is checked only if the input has value.

The input attribute data-val-checkAgainst is used to specify a number pre-defined type of expressions.

You can test for the following types of custom expressions:

Equal To | Another Input | An Array | Numeric Operators | String Operators | Date Operators | RegEx Expression

Equal To

Supply any number or string in the data-val-checkAgainst attribute that the value of the input field must match exactly:

Example:
<input type="text" name="equalto1" data-val-required="1" data-val-checkAgainst="105"  />
<input type="text" name="equalto2" data-val-required="1" data-val-checkAgainst="United States"  />
<input type="text" name="equalto3" data-val-required="1" data-val-checkAgainst="Jazz"  />