Javascript examples for DOM HTML Element:Input Password
You can create an <input> element with type="password" by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <p>Click the button to create a Password Field.</p> <button onclick="myFunction()">Test</button> <script> function myFunction() {//w ww . j a v a2 s .c o m var x = document.createElement("INPUT"); x.setAttribute("type", "password"); x.setAttribute("value", "pswtext"); document.body.appendChild(x); } </script> </body> </html>