user4671373
user4671373

Reputation:

Validation message is not shown

Here is my js and html code for gender field:

<input data-bind="value: gender, attr: {required: isMyClient}">
self.Gender = ko.observable();

Here is the js and html file for first name field:

<input name="entity" class="form-control" placeholder="Enter value" data-bind="value:FirstName">
self.FirstName = ko.observable().extend({
   required: {
       message: "fill in the blanks"
   }
})

Code for gender works fine as I am not able to submit without filling the field if MyClient is checked but there is not any validation message shown. I do not get the idea what is the reason behind that.

Upvotes: 1

Views: 142

Answers (1)

Jeroen
Jeroen

Reputation: 63729

You're using the html5 required attribute for gender, and ko-validation for the other. The first is in no real way linked to ko-validation, and I think you want to forego using it.

For reference:

To get a message you should change your setup to use a ko-validation rule for gender, and get rid of the attr binding for the required attribute.

Upvotes: 1

Related Questions