Return which type of form element the number field is:
var x = document.getElementById("myNumber").type;
Click the button to return which type of form element the number field is.
<!DOCTYPE html> <html> <body> <input type="number" id="myNumber" value="2"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w . j av a 2s. com*/ var x = document.getElementById("myNumber").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The type
property returns which type of form element the week field is.
For an input number, this property will always return "number".