我的输入类型数字代码为
<mat-form-field>
<input matInput placeholder="" formControlName="timeTaken" type="number"/>
</mat-form-field>
它确实允许接受0001,是否有任何可能的方法可以使用户在键入时单击0001时自动格式化为1并单击其他位置(当该数字字段不突出时)
因此无论您键入多少0,它在某种程度上都看起来像Windows计算器。它只显示一个0,然后按5则显示5
谢谢
您可以如下将onfocusout
事件处理程序添加到input
元素:
<input ... type="number" onfocusout="this.value = Number(this.value)"/>