SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting a TEXT field into a PASSWORD field.

    Hi,

    I know this should be pretty simple, and very possibly a stupid question, but how can I convert a text input to a password input once the text input is being clicked on.

    Shotto!
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.

  2. #2
    SitePoint Member
    Join Date
    Oct 2001
    Location
    UK
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Pip

    Try document.formname.elementname.type = "password" I am not sure offhand, however, if the is read only or not. Only one way to find out!
    Cheers,

    Keith

  3. #3
    web daemon jorasmi's Avatar
    Join Date
    Nov 2001
    Location
    Philippines
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just use
    <input type = "password">
    instead of
    <input type = "text">

  4. #4
    SitePoint Zealot easyrew's Avatar
    Join Date
    Nov 2001
    Location
    Milton Keynes, UK
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by diades
    Hi Pip

    Try document.formname.elementname.type = "password" I am not sure offhand, however, if the is read only or not. Only one way to find out!
    Looks to me like the TYPE property is read-only.

    Try this instead - a bit of cleverness with HTML, JavaScript and CSS...

    Code:
    <form name="myForm">
      Password: 
       <input type="Text" name="textObj" 
           onclick="document.myForm.textObj.style.display = 'none';document.myForm.passwdObj.style.display = 'inline';document.myForm.passwdObj.focus();" 
           value="Enter password...">
       <input type="Password" name="passwdObj" 
           value="" style="display: none">
    </form>
    Does that help?

    Rich
    If a man stands alone in the forest
    and there's no woman around to hear him,
    is he still wrong?
    w: www.EasyRew.com

  5. #5
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brilliant!

    I followed Rich's suggestion. Did it slightly different, but it works like a bomb locked on Bin Laden!

    onClick: show hidden password field and hide visible text field.
    onBlur: hide visible password field and show hidden text field.

    Mayhem! Absolute CHAOS! I love it!

    Shot Rich!
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •