问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/12991515/how-to-show-validation-error-messge-on-different-location