forked from Knockout-Contrib/Knockout-Validation
-
Notifications
You must be signed in to change notification settings - Fork 0
Validation Bindings
cyberprune edited this page Nov 18, 2012
·
5 revisions
Knockout Validation comes with several built-in bindings!
###ValidationMessage###
If you want to customize the display of your objects validation message, use the validationMessage binding:
<div>
<input type="text" data-bind="value: someValue"/>
<p data-bind="validationMessage: someValue"></p>
</div>###ValidationOptions###
If you have large areas of a form that you would like to change how the Validation Plugin is configured, use the validationOptions binding.
This will cascade your options through the children of the container that you apply this to.
Use this for:
- Custom Message Templates
- Disabling auto-inserting of messages
- Changing the Validation Message CSS Class
<div data-bind='validationOptions: { messageTemplate: "customMessageTemplate" }'>
<label>Email: <input data-bind='value: emailAddress' required pattern="@"/></label>
<label>Location: <input data-bind='value: location'/></label>
<label>Age: <input data-bind='value: age' required/></label>
</div>###ValidationElement### This toggles CSS classes on html tags bound to invalid ViewModel properties
<div>
<input type="text" data-bind="value: someValue, validationElement: someValue"/>
<p data-bind="validationMessage: someValue"></p>
</div>