B.Cos
B.Cos

Reputation: 448

Angular Material input type number auto format 0001 to 1

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

Answers (1)

uminder
uminder

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

Related Questions