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 6057949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:32:40+00:00 2026-05-23T08:32:40+00:00

I am trying something like: var usernameDone = false; /*Some application logic*/ alert(usernameDone); This

  • 0

I am trying something like:

var usernameDone = false;
/*Some application logic*/
alert(usernameDone);

This is always evaluating to undefined. However, if I change the variable name from usernameDone to anything else, even usrnameDone, the script works fine. Does usernameDone conflict with jQuery? If not, then why does it happen?

(I am testing on Chrome with jQuery-1.6.1 currently and have not tried other browsers.)

[Update]
The variable evaluates to undefined even if the application logic is eliminated.

[Update-2 The full code]
I have marked the usage using // comments

 $('document').ready( function() {

/**
 * The following set manages the effects for the login menu. The effects including highlighting
 * the login box when focused, showing guidance through a pop-up menu and handling transformation
 * through fade effects.
 * 
 */
var usernameDone = false;      //Declared here
/**
 * @function login-box focus()
 * Handles the onFocus() effects of the login box and displays the initial guidance pop-up box.
 * 
 */

$('#login-box').focus( function() {

/**
 * Color change effect of the login box
 */

    $(this).css('background-color' , '#000');
    $(this).css('color' , '#FFF');
    $(this).css('border' , '2px solid #000');

/**
 * Fade in effect of the login guide
 */

    $('#login-guide').fadeIn(1200);
    $('#login-guide-triangle').fadeIn(1200);

});


/**
 * @function login-box focusout()
 * Handles the focusOut effects of the login box and hides the guidance pop-up box.
 * 
 */

$('#login-box').focusout( function() {

/**
 * Color change effects of the login box
 */

    $(this).css('background-color' , '#FFF');
    $(this).css('color' , '#000');
    $(this).css('border' , '3px solid #000');

/**
 * Fade out effect of the login guide
 */

    $('#login-guide').fadeOut(1200);
    $('#login-guide-triangle').fadeOut(1200);
});

/**
 * @function login-box bind(keypress)
 * Handles the progression of the login steps. Specifically, what state the login box is in 
 * (ie, username or password) and how to respond when the state change key ('return/enter key')
 * is pressed.
 * 
 */

$('#login-box').bind('keypress' , function(e) {
/**
 * Checks for the current state (using usernameDone) if not, then registers the current username
 * changes the state to username done and converts the login box into password. Also, changes the
 * guidance contents.
 */
    alert(usernameDone);    //Always undefined (no modification before this)
    if(e.keyCode == 13 && usernameDone == false) {    //Owing to undefined it never evaluates to true.
        var loginUsername = $(this).val();
        $(this).val('');
        var usernameDone = true;
        $(this).fadeOut(0);
        document.getElementById('login-box').setAttribute('type' , 'password');
        $('#login-guide-title').html('Password');
        $('#login-guide-info').html('Press enter to login');
        $(this).fadeIn(800);
    }
});

});
  • 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-05-23T08:32:41+00:00Added an answer on May 23, 2026 at 8:32 am

    Of course it is going to be undefined, because you listen for a ready event on the string 'document' not on the variable document. Do NOT enclose the variable document with single or double quotes, otherwise the ready event will never fire, hence why your variable is never defined. Also, do not re-declare the variable usernameDone with var usernameDone = true;, just assign a value to it like this usernameDone = true;, because it is already defined.

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

Sidebar

Related Questions

I am trying to do something like this: var test = { a: 10,
I'm trying to do something like: var keydownHandler = function (ev) { alert(ev.data.test); return
I am trying to do something like this: var data = $('#upTar').contents(); $(#fileRes).html(data); Where
I'm trying something like this Output.py print Hello Input.py greeting = raw_input(Give me the
I'm trying to implement something like this: <div> <table> <thead> <tr> <td>Port name</td> <td>Current
I've trying to achieve something like this: class Base { public: Base(string S) {
So I am trying to accomplish something like this: SELECT * FROM table WHERE
I'm trying to do a domain lookup in vba with something like this: DLookup(island,
So, I'm trying to consume a webservice using something like this: $client = new
I'm trying something like this, but this example does not work. jsObj = {};

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.