角材料输入类型编号自动格式化0001到1

问题描述 投票:0回答:1

我的输入类型数字代码为

<mat-form-field>
<input matInput placeholder="" formControlName="timeTaken" type="number"/>
</mat-form-field>

它确实允许接受0001,是否有任何可能的方法可以使用户在键入时单击0001时自动格式化为1并单击其他位置(当该数字字段不突出时)

因此无论您键入多少0,它在某种程度上都看起来像Windows计算器。它只显示一个0,然后按5则显示5

谢谢

angular angular-material
1个回答
0
投票

您可以如下将onfocusout事件处理程序添加到input元素:

<input ... type="number" onfocusout="this.value = Number(this.value)"/>
© www.soinside.com 2019 - 2024. All rights reserved.