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

  • Home
  • SEARCH
  • 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 9226205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:46:25+00:00 2026-06-18T04:46:25+00:00

I recently started with Javascript, and I have found one issue with my password.length

  • 0

I recently started with Javascript, and I have found one issue with my password.length check.
http://jsfiddle.net/uYss7/
Code:

document.observe('dom:loaded', function() {
    $('passwordan').observe('keypress', function(event) {
        if (this.value.length < 5) {    
            this.setStyle({backgroundColor: 'blue'});

        } else {
            this.setStyle({backgroundColor: 'white'});
        }
    });
});     

Issue:

It automatically fills it with information.
I’m on 127.0.0.1, the reason the box is “passwordan” is simply because I wanted to see if Firefox remembers previously entered data after box names or id, but that doesn’t seem to be the case.
What happens is that it automatically fills in five *, and this breaks my Javascript. Its length is 5, and if I click inside the box, ctrl + a (marks the five *), and write a letter(without backspace, just replacing), it’s still white. It’s length is now 1, and it’s supposed to be blue (since length is less than 5). If I mark it, click backspace and write a letter, then it works as supposed.
Here’s an image that explains:
http://makeagif.com/media/2-02-2013/pc1TSL.gif

*

pktangyue gave me the fix:

A simple way to fix it is using keyup event instead of keypress.

Because keypress triggered before value change, while keyup triggered after it.

Thanks!
*And one more question, why is there a gray border on top after going to blue (and to white again)?

  • 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-18T04:46:26+00:00Added an answer on June 18, 2026 at 4:46 am

    A simple way to fix it is using keyup event instead of keypress.

    Because keypress triggered before value change, while keyup triggered after it.

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

Sidebar

Related Questions

I have started working recently with the new .net feature of bundling and minification
I have recently started messing about with JavaScript and building my own jQuery plugins
I have started to learn JavaScript on Codecademy recently and I was wondering where
All, I've recently started doing some javascript coding. I have used the python-mode vim
I have always been coding in java and have recently started coding in javascript
I just recently started using Netbeans, and i have been working with javascript files,
I recently started learning JavaScript and I've been a frequent user of jsfiddle since
I have recently started a personal project that uses ASP.NET MVC (RC1 at the
I recently started programming C on Mac OS X (10.7.4). I have the various
I recently started working on a multi-file upload HTTP page for a customer. He

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.