Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
83
rated 0 times [  90] [ 7]  / answers: 1 / hits: 24447  / 14 Years ago, sat, july 24, 2010, 12:00:00

i am having a simple html text box what i want just as the user type something in it the text should be invisible but the text should be there



<html>
<head>
<title>My Page</title>
<script type=text/javascript>
function hide()
{
document.forms[text].style.visibility = 'hidden';
}
</script>

</head>
<body>
<form name=myform>
<div align=center>
<input type=text size=25 onkeyup=return hide();>
</div>
</form>
</body>
</html>

More From » html

 Answers
120

Mac,



What you're doing is kind-of impossible to accomplish using straightforward means. When you use the code you've included in the question, you're actually removing the visibility of the entire box, not just the text content.



Some ideas:




  1. Make the textcolor the same as the background color.

  2. Use the onKeyPress event, after every keystroke take the value from this box, and append it into a hidden textbox you've got elsewhere on the page (or a javascript variable.



Combining these should be pretty effective in what you're tryin to do.



More important is the question: Why would you want to do this? Could you elaborate on what it is you're trying to accomplish here?



Edit: I see you're doing this for passwords. In that case, why not use the <input type=password> field? That way the browser know it's a password field and hides the input automatically (using the standard dots, or stars).


[#96125] Wednesday, July 21, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kennedi

Total Points: 702
Total Questions: 109
Total Answers: 111

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
kennedi questions
;