Hi,
I have a textbox for a password. I want to watermark it. I can't figure out how to use JavaScript to change the textmode so the "Password" will display with no entry and "*******" will display for an entry.
Any ideas?
TIA,
Matt
Printable View
Hi,
I have a textbox for a password. I want to watermark it. I can't figure out how to use JavaScript to change the textmode so the "Password" will display with no entry and "*******" will display for an entry.
Any ideas?
TIA,
Matt
yOU CAN TRY THIS BUT I AM NOT SURE IF IT WORKS IN IEXPLORER
Assuming that you have a textbox as foloows:Code:
var element=document.getElementById("textPwd");
var element2= element.cloneNode(false);
element2.type='password';
element.parentNode.replaceChild(element2,element);
<asp:TextBox TextMode="SingleLine" runat="server" ID="textPwd"></asp:TextBox>
No, that does not work in IE. Thanks though.
Any other ideas?
But why you insist on JavaScript when you can use VB.NET to do what you want.
Code:textPwd.TextMode = TextBoxMode.Password
Hey,
Would this be of any use to you?
Hope this helps!!
Gary
Why can't you just watermark it with CSS?
That would require a postback when the user clicks on the textbox.Quote:
Originally Posted by selanec
Here's how you would do it with javascript
CSS would be similar, you'd need to set an image (background-image) and in an onclick or onfocus, remove the style that contains the background image.Code:<input type="textbox" value="Password" onclick="this.value='';this.type='password';" />