Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:39:00+00:00 2026-06-13T06:39:00+00:00

I try to do a form with the information in the same input. It

  • 0

I try to do a form with the information in the same input. It works fine in all the inputs but in the password it would be better if it could change to points when the user introduces the password. I want it to be type text and change to type password ONLY when the user introduces the password. The problem is in the last line of code:

I have it life here: http://jsfiddle.net/Nt9gx/

<form> 

<input type="text" name="name" value="name" 
    onfocus="if (this.value=='name') this.value = '';" 
    onblur="if (this.value=='') this.value = 'name';"  
/>

<input type="text" name="password" value="password"   
    onfocus="if (this.value=='password') this.value = '' type = password;" 
    onblur="if (this.value=='') this.value = 'password';"
           "if (this.value!=''|| 'password') type = password ;" 
/>

</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:39:02+00:00Added an answer on June 13, 2026 at 6:39 am

    Use the HTML5 placeholder

    To get the job done, you should simply use the HTML5 placeholder-attribute, like this:

    <input type="password" name="password" placeholder="Password">
    

    As this will:

    • show the placeholder, while no text is inserted or if all text is removed again
    • it shows the text even on a password field
    • no need using JavaScript

    By the way:

    • you used two times onblur on the last input, this should occur only once
    • the last line is syntactically wrong, as you need to escape the word password in ' (single quotes) instead of " (double quotes) (question was updated)
    • the last line uses an undefined variable called password in || password)
    • use type="password" for input fields that handle, well, passwords, as the input will be “invisible”

    Note:

    If you still want to use JavaScript, you have to change the input from type="text" to type="password" within the focus and blur events by simply updating the type-attribute.

    This is how you can do it:

    <input type="text" name="password" value="password"   
        onfocus="if (this.value == 'password') { this.value = '', this.setAttribute('type','password'); }" 
        onblur="if (this.value == '') { this.value = 'password', this.setAttribute('type','text'); }"
    >
    

    Demo: http://jsfiddle.net/2Ps8N/​

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in my application where technicians input information about different events
How can I submit jQuery form object (not ajax)? I try form.submit() and it
In a sort of try/catch form I want to execute a bash that doesn't
http://www.dorsetdesigns.co.uk/contact.html try the form it wont send a email to me. i am using
I'm try to validate form using jquery validation plugin my from code: source code
We have used Google form, Wufoo form to try to securely capture the info
i try to validate the form before submitting the request. i am using jquery
I try to create a form that can save a person's form data so
I try to make a registration form. When user post the fields, i check
I try to draw a table on a panel in C# Windows Form by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.