Angular2 radio button validation

三世轮回 提交于 2019-12-25 02:47:24

问题


How to validate radio button and checkbox and zip code in angular 2 i tried but not working.Anyone can find the solutions.please help me to resolve this issue. Demo:https://stackblitz.com/edit/angular-7-template-driven-form-validation-ndspdl?file=app/app.component.html

    <div class="form-group">
    Radio Buttons:
    <div *ngFor="let enum of enum_details">
    <label for="enum_answer_{{enum.name}}">
    <input id="enum_answer_{{enum.name}}" [value]='enum.name' type="radio" 
    name="enums" enums="ngModel" [(ngModel)]="radioSelected">
    {{enum.name}}
    </label>
    </div>  
    </div>  

    <div class="form-group">
    Checkboxes:
    <div *ngFor="let item of items; let i = index" class="checkbox"> 
        <label for="{{item.id}}">
            <input type="checkbox" value="{{item.id}}" required id=" 
    {{item.id}}" #chk="ngModel" [(ngModel)]="item.isSelected" 
   name="name+str(i)" (change)="CheckBoxChanged(i,$event)" />
            <span class="text-body">{{item.name}}</span>
        </label>
    </div>
    </div>

来源:https://stackoverflow.com/questions/55344933/angular2-radio-button-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!