【发布时间】:2018-12-27 23:57:42
【问题描述】:
你能告诉我当用户只输入 3 位数字(不是字母)时如何验证表格,那么它是有效的表格,否则无效。我尝试使用 maxength 和 minlength 但不工作。这是我的代码
https://stackblitz.com/edit/angular-cttwtq?file=src%2Fapp%2Fapp.component.ts
constructor(private fb: FormBuilder) {
this.paymentForm = this.fb.group({
cardname: ['', [Validators.required , Validators.minLength(3),Validators.minLength(3)]],
});
【问题讨论】:
-
使用npmjs.com/package/numeric-formatter.. 它将阻止用户输入超过长度的数字
标签: javascript angular