Search for a command to run...
Last updated June 9, 2026
The data-ctrovalidate-if attribute allows you to define dependencies between fields. Validation for a field only executes when the specified condition on a "controller" field is met.
The directive follows the format controllerName:conditionType[=value].
: separates the controller field name from the condition type= (for value type only) separates the condition type from the expected valuechecked)Validates the target only when the controller (checkbox or radio) is checked.
<input type="checkbox" name="shipping_separate" id="shipping" />
<input
name="shipping_address"
data-ctrovalidate-rules="required"
data-ctrovalidate-if="shipping_separate:checked"
/>value)Validates the target only when the controller's current value equals the specified string. Note the = sign between type and value.
<select name="method">
<option value="none">None</option>
<option value="express">Express</option>
</select>
<input
name="express_code"
data-ctrovalidate-rules="required"
data-ctrovalidate-if="method:value=express"
/>present)Validates the target only when the controller has a truthy value. This is the default if no condition type is provided.
<input name="referral_code" />
<input
name="referrer_name"
data-ctrovalidate-rules="required"
data-ctrovalidate-if="referral_code"
/>Equivalent explicit form:
data-ctrovalidate-if="referral_code:present"realTime is enabled, the controller field's input event triggers re-validation of all its dependents.checked, value, or present, the dependency is treated as unmet (field is skipped).