按Enter键,angular2形式验证器

时间:2016-06-02 10:57:32

标签: forms angular submit requiredfieldvalidator

按下回车,我提交了一份表格。但是当我按回车键时,表单已提交但验证程序未运行

<form [ngFormModel]="form"  (keyup.enter)="updateApplicationLink()">
   <input  [(ngModel)]="table.labelFR"   ngControl="labelfr">

constructor(fb: FormBuilder) {
  this.form= fb.group({
      labelfr: new Control('', Validators.required)
  });

1 个答案:

答案 0 :(得分:1)

尝试此操作以进行必要的验证:

<input ng-model="labelFR" required>
<h1>{{form.labelFR.$valid}}</h1>