Reputation: 448
I have a input type number code of
<mat-form-field>
<input matInput placeholder="" formControlName="timeTaken" type="number"/>
</mat-form-field>
It do allow to accept 0001, do it have any possible way to make 0001 auto format become 1 when user key in and click other place (when unfocused this number field)
So it can somehow look like windows calculator, on windows calculator no matter how many 0 you type. It just show a single 0 then next press 5 it show 5
Thank you
Upvotes: 1
Views: 2211
Reputation: 26150
You can add onfocusout
event handler to your input
element as follows:
<input ... type="number" onfocusout="this.value = Number(this.value)"/>
Upvotes: 2