SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    webdesign Percept's Avatar
    Join Date
    Jan 2003
    Location
    Belgium
    Posts
    397
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Turning a regular input filed into a password type field

    Hi,

    here's what I would like to accomplish.

    I have an input field for the users name and I have one for their password.
    Now when they come onto the page I want to have the value for the username filed say "username" and the passwordfield should say "password". Then when the users focusses on the password input the input type should turn password so when they type their password it shows like "*******".

    I someone understands what I'm trying to say

    Thanks in advance,
    Percept.


  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    HTML Code:
    <input type="text" name="myfield" id="myfield" value="password" 
    onfocus="this.setAttribute('type', 'password');this.value='';" />
    If you want to, you can move the code in the onfocus event into a function.

    I also don't recommend this as your best option, since if a user has JS disabled the password will be displayed clear as day to anybody passing by his/her monitor. This may not leave a good impression of your site's security from the user's standpoint.

  3. #3
    webdesign Percept's Avatar
    Join Date
    Jan 2003
    Location
    Belgium
    Posts
    397
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks Vinnie.

    Maybe the default type could be password and if javascript is enabled I could "overwrite" the type to regular input? ( and then back to password again if they focus it )


  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Percept
    Thanks Vinnie.

    Maybe the default type could be password and if javascript is enabled I could "overwrite" the type to regular input? ( and then back to password again if they focus it )
    Very good alternative approach there. I say go with that

  5. #5
    webdesign Percept's Avatar
    Join Date
    Jan 2003
    Location
    Belgium
    Posts
    397
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Allrighty

    Thanks Vinnie.



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
  •