javascript - Validation form on dependant radio button -


i'm working on project in witch need have custom validation on form dependant radio button or checkboxes.

here html code,

<form name="form" nonvalidate ng-controller="part6ctrlform"> . . . <md-input-container class="choice">                 <input name ="is-correct"type="radio" ng-value="true" ng-model="choise.is_correct"/>               </md-input-container>                 <!-- <md-checkbox share-validate ng-model="choice.is_correct" aria-label="is correct ?">                     correct ?                 </md-checkbox> -->  </form> 

i have 2 possibility, need have 1 checkbox or radio checked , set true value when it's checked. problem can't find way form validation on rule.

i have tried code in js i'm new angular , after lot search haven't find me.

$scope.validresponses = function () {          this.sum = 0;         this.valid = false;         this.tmpbool = 0;          (i ; i<choices.length ; i++)         {             this.tmpbool = $scope.choices[i].is_correct ? 1 :0;             this.sum += this.tmpbool;         }         console.log(sum);          return sum===1 ? true : false;     }; 

this function try count how many checkboxes checked i'm not familiar $scope , it's not working.

thank help.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -