I am using knockout.js & knockout.validation
plugins. I am adding the example fiddle
http://jsfiddle.net/hsnCW/1/
In this example there is a custom validation for array to check duplicate entries. But my problem is with the validation message. By default the error message inserted just after the element on which validation is applied.But i want to show message on some different place. How can i do this?
On the Home tab, click Add Rule, click Is Not Between, and then click Show Validation Error.
In order to display error messages on forms, you need to consider the following four basic rules: The error message needs to be short and meaningful. The placement of the message needs to be associated with the field. The message style needs to be separated from the style of the field labels and instructions.
The Validation Error Message property lets you define a custom error message to display if the validation checks specified in the Validation (Regex) fails.
You can use the validationMessagebinding
to display any of your proerties error message:
<p data-bind="validationMessage: newItem"></p>
And you can disable the automatically inserted validation message with the validationOptions
binding:
<span data-bind="validationOptions: { insertMessages: false}">New Item:
<input data-bind="value:newItem" />
<button data-bind="click: addItem">Add</button>
</span>
See the documentation Validation Bindings section for more info.
Demo JSFiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With