Knockout validation on select lists with no data-bind 'option' or 'caption'

Is it possible to have knockout validation on a select list that does not include a data-bind 'option' or 'optionCaption'?

My select looks like the following:

<select data-bind="value: viewModels.vm.MyValue">
                        <option>--Please Select--</option>
                        <option value="yes">Yes</option>
                        <option value="no">No</option>

My validation looks like:

viewModels.vm.MyValue= ko.observable().extend({
        required: {
            params: true,
            message: " (you must make a selection)"

I was hoping that as the top option did not have a value then the validation would kick in.

Is there any way of telling the validation if it is a certain record to ignore it?

I cannot actually bind the values to the observable as the model is being passed in and mapped via json

Any help would be great


Since your first <option> doesn't define a value attribute, the browser uses the caption ("--Please Select--") as the element's value, and the validator rightfully treats it as valid.

Try this:

<option value="">--Please Select--</option>

Need Your Help

Django date form field can't accept |date:"SHORT_DATE_FORMAT" filter

python django forms django-templates

When looping over form fields for a ModelForm, I can apply the date filter to a models.DateField() just fine, i.e.

How to build a composite Rack application?

ruby-on-rails ruby sinatra rack

I am trying to build an application that uses Sinatra for rendering the views, and handles file uploads, while using another library for handling web socket communication (em-websocket). Normally, em-