javascript - Validation for radio in knockout js -


i have list radio got ajax:

<div data-bind="foreach: availableservices">     <div class="row">          <label>              <span class="cb"><input type="radio" name="service" data-bind="attr:{value: number}, checked: $root.selectedservice"></span>              <span data-bind="text: name"></span>              <span data-bind="text: price"></span>€              <span data-bind="text: duration"></span>min           </label>      </div> </div> 

i want show error when radio not checked validation knockout. can u me? thanks

you can use next binding it:

    <span style="color: red;" data-bind="text: 'please, select service',         visible: !selectedservice()">   

this span should outside of <div data-bind="foreach
jsfiddle demo