1
我正在使用angular 2 formbuilder來創建表單。我只想輸入正數值到量字段(minValue是0,maxvalue是100) 如何使用angular2 formbuilder執行最小和最大驗證。angular 2 formbuilder min max validation
HTML代碼
<form class="form-horizontal"
novalidate
(ngSubmit)="splitCharges()"
[formGroup]="splitChargeForm" >
<input type="number" id="sequenceId" placeholder="Amount" formControlName="amount" >
</form>
角度成分
constructor(private fb: FormBuilder){}
ngOnInit() {
this.splitChargeForm = this.fb.group({
amount: ['', Validators.required], // want to set min=0 and max=100 validations for this field
percentage: ['', Validators.required]
});
}
@KetanAkbari'minLength'和'maxLength'並不是我所瞭解的問題。 –
好吧,它幫助我。謝謝 –