Use two decimals in the number type input, ideal for prices

- Andrés Cruz

En español

Use two decimals in the number type input, ideal for prices

Many times we have a text field which we want to represent a price or ultimately a numerical value with a decimal part; if you are up to date with HTML5, you know that you can define a field of type number

Tengo un <input type = "number">

The problem is, it will only accept integer numbers; If you want a decimal part, which is our goal, you have to define the step parameter, to indicate the interval; in our case, we want it to be two decimal places:

step=".01"

If you wanted, for example, 3

step=".001"

Definitely:

<input type = "number" step=".01">
Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.

!Courses from!

10$

On Udemy

There are 1d 12:45!


Udemy

!Courses from!

4$

In Academy

View courses

!Books from!

1$

See the books
¡Become an affiliate on Gumroad!