subramani
subramani

Reputation: 1069

KnockoutJs + Jquery Plugin Validation

Using KnockoutJS + JQuery Validation, all the control validation is working fine. While Radio btn validation is not working.

Issue 1: * is displayed near to radio btn

Male Female

output: * Male Expected output : Male * output: * Female Expected output : Female *

Issue 2: While applying Class=Required both radio buttons are mandatory, how we will resolve the issue

Issue 3: Same thing happend for dynamic radio buttons as well. All are available in the same page.

Guide me......

Upvotes: 0

Views: 302

Answers (2)

Andy Brudtkuhl
Andy Brudtkuhl

Reputation: 3652

  1. Make sure your radio buttons have the same "name" attribute (this is the case with jquery validation regardless of using knockout)

  2. You only need to add required class to one of them if you do my first point above

  3. Dynamic radio buttons need to have specific names (and names need to be same for all buttons you want to validate in a group)

For instance, I have this foreach loop that validates the radiobuttons correctly because they have unique names

<input type="radio" data-bind="attr: { name: 'options-' + $index() }" class="required" value="Yes" checked />
<input type="radio" data-bind="attr: { name: 'options-' + $index() }" value="No" checked />

Upvotes: 0

Anders
Anders

Reputation: 17554

Try the knockout validation, it works so much nicer together with knockout

https://github.com/ericmbarnard/Knockout-Validation

Upvotes: 1

Related Questions