DOM Properties
HTMLInputElement.valueAsNumber
Read/write for supported input types. Converts the control value to a number, or NaN when empty or not convertible. For date-related inputs the numeric meaning depends on the input type, rather than always representing a plain quantity. Example result: 14.5.
Formal Syntax & Structure
html syntaxhtml
element.valueAsNumberReturn Value
number
Property value. Read/write for supported input types.
Working Example
Example Snippethtml
<input id="demo" type="number" value="12.5"><p> Result: <output id="result"></output></p><script> const e = document.getElementById('demo'); const result = value => { document.getElementById("result").textContent = String(value); }; result(e.valueAsNumber+2);</script>Browser Compatibility
Minimum supported versions across modern rendering engines
Chrome
5
Yes
Edge
12
Yes
Firefox
16
Yes
Safari
5
Yes
Opera
≤12.1
Yes
Checked desktop BCD snapshot: HTMLInputElement.valueAsNumber property; applicable types only. Versions denote the recorded start of support (≤ means at least that early), not a guarantee of all behavior. Unresolved mirror and preview rows omitted.
HTML Living Standard