We can create an <input> element with type="number" via the document.createElement()
method:
var x = document.createElement("INPUT"); x.setAttribute("type", "number");
Click the button to create a Number field.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from ww w .ja va 2 s. c om var x = document.createElement("INPUT"); x.setAttribute("type", "number"); x.setAttribute("value", "12345"); document.body.appendChild(x); } </script> </body> </html>