The number type has a step value controlling which numbers are valid (along with max and min), which defaults to 1. This value is also used by implementations for the stepper buttons (i.e. pressing up increases by step).

Simply change this value to whatever is appropriate. For money, two decimal places are probably expected:

<label for="totalAmt">Total Amount</label>
<input type="number" step="0.01" id="totalAmt">

(I'd also set min=0 if it can only be positive)

If you'd prefer to allow any number of decimal places, you can use step="any" (though for currencies, I'd recommend sticking to 0.01). In Chrome & Firefox, the stepper buttons will increment / decrement by 1 when using any. (thanks to Michal Stefanow's answer for pointing out any, and see the relevant spec here)

Here's a playground showing how various steps affect various input types:

<form>
  <input type=number step=1 /> Step 1 (default)<br />
  <input type=number step=0.01 /> Step 0.01<br />
  <input type=number step=any /> Step any<br />
  <input type=range step=20 /> Step 20<br />
  <input type=datetime-local step=60 /> Step 60 (default)<br />
  <input type=datetime-local step=1 /> Step 1<br />
  <input type=datetime-local step=any /> Step any<br />
  <input type=datetime-local step=0.001 /> Step 0.001<br />
  <input type=datetime-local step=3600 /> Step 3600 (1 hour)<br />
  <input type=datetime-local step=86400 /> Step 86400 (1 day)<br />
  <input type=datetime-local step=70 /> Step 70 (1 min, 10 sec)<br />
</form>
Run code snippetEdit code snippet Hide Results Copy to answer Expand


As usual, I'll add a quick note: remember that client-side validation is just a convenience to the user. You must also validate on the server-side!

Answer from Dave on Stack Overflow
🌐
CodePen
codepen.io › dylanbox › pen › MWjxrR
Double Input Form
<html> <body> <section> <h1>My cool form</h1> <form action=""> <label for="first-name">Name</label> <div class="double-input"> <input type="text" id="first-name" placeholder="First" /> <input type="text" id="last-name" placeholder="Last"/> </div> <button class="btn">Submit</button> </form> </section> </body> </html> !
Top answer
1 of 13
2477

The number type has a step value controlling which numbers are valid (along with max and min), which defaults to 1. This value is also used by implementations for the stepper buttons (i.e. pressing up increases by step).

Simply change this value to whatever is appropriate. For money, two decimal places are probably expected:

<label for="totalAmt">Total Amount</label>
<input type="number" step="0.01" id="totalAmt">

(I'd also set min=0 if it can only be positive)

If you'd prefer to allow any number of decimal places, you can use step="any" (though for currencies, I'd recommend sticking to 0.01). In Chrome & Firefox, the stepper buttons will increment / decrement by 1 when using any. (thanks to Michal Stefanow's answer for pointing out any, and see the relevant spec here)

Here's a playground showing how various steps affect various input types:

<form>
  <input type=number step=1 /> Step 1 (default)<br />
  <input type=number step=0.01 /> Step 0.01<br />
  <input type=number step=any /> Step any<br />
  <input type=range step=20 /> Step 20<br />
  <input type=datetime-local step=60 /> Step 60 (default)<br />
  <input type=datetime-local step=1 /> Step 1<br />
  <input type=datetime-local step=any /> Step any<br />
  <input type=datetime-local step=0.001 /> Step 0.001<br />
  <input type=datetime-local step=3600 /> Step 3600 (1 hour)<br />
  <input type=datetime-local step=86400 /> Step 86400 (1 day)<br />
  <input type=datetime-local step=70 /> Step 70 (1 min, 10 sec)<br />
</form>
Run code snippetEdit code snippet Hide Results Copy to answer Expand


As usual, I'll add a quick note: remember that client-side validation is just a convenience to the user. You must also validate on the server-side!

2 of 13
219

Via: http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/

But what if you want all the numbers to be valid, integers and decimals alike? In this case, set step to “any”

<input type="number" step="any" />

Works for me in Chrome, not tested in other browsers.

🌐
MaxInterview
maxinterview.com › code › html-double-input-623C504FF8BC60E
MaxInterview - html double input
April 5, 2022 - ml inputy type floatinput type number support floating pointinput type decimal htmlhtml input field numbers with decimalinput floathow to give a input of type decimal in htmlhtml input number no decimalhtml number field decimalmake number input to be accept as floatinput type 3d 22number 22 decimalinput double htmlinput type 3dnumber pattern decimalinput type decimals htmldecimals in forms htmlfloat number in htmlhtml5 float inputinput number html decimalhtml form decimal inputhtml input type number no decimalsinput type float number in htmlinput type decimal numberinput type number is not sho
🌐
GitHub
github.com › eclipse-ee4j › krazo › issues › 118
Double format problems when using <input type="number"> · Issue #118 · eclipse-ee4j/krazo
November 28, 2019 - Description I recognized that the NumberConverter can't handle decimals from a number input field properly when using a non-english (or better: not-dot separated) locale. Because the browser only sends dot-separated values to the server,...
Author: eclipse-ee4j
🌐
Quora
quora.com › How-do-I-take-an-input-type-float-number-in-HTML
How to take an input type float number in HTML - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
GitHub
github.com › aspnet › Mvc › issues › 2780
Do not use type=number for double and single · Issue #2780 · aspnet/Mvc
July 3, 2015 - Currently, the tag helpers and default editor templates use type=number for double and single, but type=text for decimal. There are a very good reason not to use type=number, which are browser support (IE as usual) and internationalization (model ...
Author: aspnet
🌐
Enonic
developer.enonic.com › docs › xp › stable › cms › schemas › input-types › double
Double input type - Enonic Developer Portal
November 21, 2023 - <input name="mydouble" type="Double"> <label>My Double</label> <default>3.89</default> (1) </input> <input name="angle" type="Double"> <label>Angle (rad)</label> <config> <min>0</min> (2) <max>3.14159</max> (3) </config> </input>
🌐
W3Schools
w3schools.com › tags › att_input_type_number.asp
HTML input type="number"
The <input type="number"> defines a field for entering a number. Use the following attributes to specify restrictions: ... Tip: Always add the <label> tag for best accessibility practices! ... Coding fundamentals as bite-sized lessons and challenges. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
Find elsewhere
🌐
W3Schools
w3schools.com › html › html_form_input_types.asp
HTML Input Types
HTML Examples HTML Editor HTML Quiz HTML Exercises HTML Challenges HTML Website HTML Syllabus HTML Study Plan HTML Interview Prep HTML Summary HTML Accessibility · HTML Tag List HTML Attributes HTML Global Attributes HTML Browser Support HTML Events HTML Colors HTML Canvas HTML Audio/Video HTML Doctypes HTML Character Sets HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods PX to EM Converter Keyboard Shortcuts ... This chapter describes the different types for the HTML <input> element.
🌐
GeeksforGeeks
geeksforgeeks.org › html › how-to-set-float-input-type-in-html5
How to set float input type in HTML5 ? - GeeksforGeeks
July 23, 2025 - However, there are other ways to accept these types of values. Approaches to accept floating-point numbers in HTML: Using the step attribute: This attribute is used to specify the increment at which a value can be increased or decreased. By setting the step attribute to a decimal value, floating-point numbers can be accepted as input.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Element › input › number
<input type="number"> HTML attribute value - HTML | MDN
It is not as semantically useful as other ways to explain your form, and can cause unexpected technical issues with your content. See <input> labels for more information. A Boolean attribute which, if present, means this field cannot be edited by the user. Its value can, however, still be changed by JavaScript code directly setting the HTMLInputElement value property.
🌐
W3C
w3c.github.io › html-reference › input.number.html
input type=number – number input control (NEW) - HTML5
The input element with a type attribute whose value is "number" represents a precise control for setting the element’s value to a string representing a number.
🌐
W3Schools
w3schools.com › tags › att_input_type.asp
HTML input type Attribute
The type attribute specifies the type of <input> element to display.
🌐
Wufoo
wufoo.com › home › html5 web resource and guide › html5 forms: number type
HTML5 Forms: Number Type | Wufoo
July 30, 2019 - The pattern and size attributes are not relevant for the number type and will be ignored if included. When min, max and step are set, some browsers may display a narrower input box for number input type, as the width of the widest valid value is limited.
🌐
Coderanch
coderanch.com › t › 113688 › languages › input-double-quotes-input-field
input double quotes in input field (HTML Pages with CSS and JavaScript forum at Coderanch)
May 9, 2003 - If your looking to pass values with double quotes , posting the form must achieve it. If you are looking for an escape sequence, the there is an escape() method in javascript i think which will achieve that ... Not sure what you are asking,,,, say you have this line: string="THis has more quotes " " in it"; And that results in an error You can do it by escapeimg the center quotes, " or the easier ways string="THis has more quotes \" \" in it"; OR string='THis has more quotes " " in it'; Is that what you are asking?
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › input › number
<input type="number"> HTML attribute value - MDN Web Docs
September 10, 2026 - It is not as semantically useful as other ways to explain your form, and can cause unexpected technical issues with your content. See <input> labels for more information. A Boolean attribute which, if present, means this field cannot be edited by the user. Its value can, however, still be changed by JavaScript code directly setting the HTMLInputElement value property.
🌐
W3Schools
w3schools.com › tags › att_input_multiple.asp
HTML input multiple Attribute
<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hgroup> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <menu> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <
🌐
W3C
w3.org › TR › 2010 › WD-html-markup-20101019 › input.number.html
HTML5: input type=number – number input control (NEW)
interface HTMLInputElement : ... type; attribute DOMString defaultValue; attribute DOMString value; attribute Date valueAsDate; attribute double valueAsNumber; readonly attribute HTMLOptionElement selectedOption; attribute DOMString width; void stepUp(in optional long ...