Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show validation error messge on different location?

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?

like image 399
Tom Rider Avatar asked Oct 20 '12 18:10

Tom Rider


People also ask

Where we can show error message in validation rule?

On the Home tab, click Add Rule, click Is Not Between, and then click Show Validation Error.

How do I display an error message in a form?

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.

What is validation error message?

The Validation Error Message property lets you define a custom error message to display if the validation checks specified in the Validation (Regex) fails.


1 Answers

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.

like image 50
nemesv Avatar answered Oct 24 '22 05:10

nemesv