|
-
Sep 11th, 2008, 08:34 PM
#1
Thread Starter
Hyperactive Member
[2005] Watermark Password TextMode TextBox
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
VS 2010 / .NET 4.0 / ASP.NET 4.0
-
Sep 12th, 2008, 08:09 AM
#2
Fanatic Member
Re: [2005] Watermark Password TextMode TextBox
yOU CAN TRY THIS BUT I AM NOT SURE IF IT WORKS IN IEXPLORER
Code:
var element=document.getElementById("textPwd");
var element2= element.cloneNode(false);
element2.type='password';
element.parentNode.replaceChild(element2,element);
Assuming that you have a textbox as foloows:
<asp:TextBox TextMode="SingleLine" runat="server" ID="textPwd"></asp:TextBox>
-
Sep 12th, 2008, 08:14 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Watermark Password TextMode TextBox
No, that does not work in IE. Thanks though.
Any other ideas?
VS 2010 / .NET 4.0 / ASP.NET 4.0
-
Sep 12th, 2008, 09:10 AM
#4
Fanatic Member
Re: [2005] Watermark Password TextMode TextBox
But why you insist on JavaScript when you can use VB.NET to do what you want.
Code:
textPwd.TextMode = TextBoxMode.Password
-
Sep 12th, 2008, 01:39 PM
#5
Re: [2005] Watermark Password TextMode TextBox
Hey,
Would this be of any use to you?
Hope this helps!!
Gary
-
Sep 12th, 2008, 01:54 PM
#6
Re: [2005] Watermark Password TextMode TextBox
Why can't you just watermark it with CSS?
-
Sep 13th, 2008, 07:02 AM
#7
Re: [2005] Watermark Password TextMode TextBox
 Originally Posted by selanec
But why you insist on JavaScript when you can use VB.NET to do what you want.
Code:
textPwd.TextMode = TextBoxMode.Password
That would require a postback when the user clicks on the textbox.
Here's how you would do it with javascript
Code:
<input type="textbox" value="Password" onclick="this.value='';this.type='password';" />
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|