Results 1 to 7 of 7

Thread: [2005] Watermark Password TextMode TextBox

  1. #1

    Thread Starter
    Hyperactive Member mulhearn22's Avatar
    Join Date
    Jun 2007
    Location
    Cherry Hill, NJ
    Posts
    347

    [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

  2. #2
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    592

    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>

  3. #3

    Thread Starter
    Hyperactive Member mulhearn22's Avatar
    Join Date
    Jun 2007
    Location
    Cherry Hill, NJ
    Posts
    347

    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

  4. #4
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    592

    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

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2005] Watermark Password TextMode TextBox

    Hey,

    Would this be of any use to you?

    Hope this helps!!

    Gary

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] Watermark Password TextMode TextBox

    Why can't you just watermark it with CSS?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Watermark Password TextMode TextBox

    Quote 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
  •  



Click Here to Expand Forum to Full Width