Javascript examples for DOM HTML Element:Input Text
Mask input text output from a form
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script> function displayNumber(){// w ww .j av a 2 s .c om var card = document.getElementById('credit').value; var str = ""; for(var i=1; i <= card.length-4; i++) { str += "*"; } ecard = str + card.substr(card.length-4); document.getElementById('credit').value = ecard; } </script> <form id="myform"> <input type="text" id="credit" onkeyup="displayNumber()"> </form> </body> </html>