Javascript 依赖项单选按钮上的验证表单

Javascript 依赖项单选按钮上的验证表单,javascript,angularjs,Javascript,Angularjs,我在一个项目中工作,我需要从依赖单选按钮或复选框对表单进行自定义验证 这是我的HTML代码 <form name="form" nonvalidate ng-controller="Part6CtrlForm"> . . . <md-input-container class="choice"> <input name ="is-correct"type="radio" ng-value="true" ng-model="choise

我在一个项目中工作,我需要从依赖单选按钮或复选框对表单进行自定义验证

这是我的HTML代码

<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 ?">
                    Is correct ?
                </md-checkbox> -->

</form>

.
.
.
我有两种可能,我只需要有一个复选框或收音机被选中,并设置一个真正的值时,它被选中。 我的问题是,我找不到一种方法来对该规则进行表单验证

我尝试过js中的一些代码,但我对angular是新手,所以即使经过大量搜索,我也没有找到任何对我有帮助的东西

$scope.validResponses = function () {

        this.sum = 0;
        this.valid = false;
        this.tmpBool = 0;

        for (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;

   };
$scope.validResponses=函数(){
此值为0.sum=0;
this.valid=false;
this.tmpBool=0;

对于(i;i;单选按钮应该是单选机制。如果你这样做,你不需要验证它。单选按钮应该是单选机制。如果你这样做,你不需要验证它。单选按钮应该是单选机制。你不会需要验证它,如果你要这样做