javascript - HTML terminal like text input -
i trying have form field (just normal html text input box) can typed in , have value changed renders text invisible.
i need box visible visibility: hidden;
or display: none;
won't trick.
i can't make text same color background because background not single color. need text invisible while rest of input remains visible.
the effect trying achieve when type password in terminal , accepts input shows no feedback (this not password though).
i can't make text same color background because background not single color.
what transparent
color?
does help?
input[type="text"] { color: transparent; }
update:
i implemented @shomz idea, can keep cursor @ beginning or change characters *
. i've used jquery
bind event:
jquery version:
var holder = [], exceptions = [13]; var hidechar = function(elm) { elm.value = ''; // or // elm.value = elm.value.replace(/[^*]/, '*'); }; $('#console').keydown(function(e) { if (e.which === 8) { holder.pop(); } }).keypress(function(e) { if ($.inarray(e.which, exceptions) === -1) { holder.push(string.fromcharcode(e.which)); } var _this = this; settimeout(function() { hidechar(_this); }, 1); }).keyup(function() { $('#holder').val(holder.join('')); });
html:
<input id="console" type="text" value=""> <input id="holder" type="hidden">
pure javascript version? sure!
that's long story, check demo.
Comments
Post a Comment