DEV Community

Faisal Ahmed
Faisal Ahmed

Posted on

Decimal Value input in angular

You want to type decimal, but use digitOnly, so you can't. so use step="0.01"

so that after adding, your value is number

`
problem`

`html
<mat-form-field appearance="outline">
<mat-label>Regular Price</mat-label>
<input formControlName="variationRegularPrice" type="number" digitOnly matInput />
<mat-error>This field is required.</mat-error>
</mat-form-field>
`

solution
`html
<mat-form-field appearance="outline">
<mat-label>Regular Price</mat-label>
<input formControlName="variationRegularPrice" type="number" step="0.01" matInput />
<mat-error>This field is required.</mat-error>
</mat-form-field>
`

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay