Ngx-mask 对生产中的输入字段强制验证

GUR*_*ANI 6 javascript input-mask angular7

我的输入看起来像这样:我只想使用输入掩码但不强制用户严格填充掩码中的模式。

<input type="text" class="Enter Zipcode" placeholder="Enter Zipcode" mask="00000-0000" formControlName="zipcode">
Run Code Online (Sandbox Code Playgroud)

似乎根据文档[validation]=true 默认情况下。但应该是某种方式将验证更改为false。当我这样做时

<input type="text" class="Enter Zipcode" placeholder="Enter Zipcode" mask="00000-0000" formControlName="zipcode" [validation]="true">

ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'validation' since it isn't a known property of 'input'. ("text" class="Enter Zipcode" placeholder="Enter Zipcode" mask="00000-0000" formControlName="zipcode" [ERROR ->][validation]="false">
Run Code Online (Sandbox Code Playgroud)

Angular 抛出模板解析错误?

小智 5

使用mask="99999-9999"。根据 ngx-mask 文档,0 用于必需的数字字段,9 用于可选的数字字段。