javascript DOM.value doesn't have autofill information

RESOLVED DUPLICATE of bug 221634

Status

()

Firefox
General
RESOLVED DUPLICATE of bug 221634
12 years ago
12 years ago

People

(Reporter: Jon Stevens, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7

Say I have a form like this:

<form>
  <input type="text" name="username" value="" />
  <input type="text" name="password" value="" />
</form>

Now, I load the page and autofill fill's in the username/password for me. Thus, one would think this would work:

<form>
  <input type="text" name="username" id="username" value="" />
  <input type="password" name="password" id="password" value="" />
  <input type="submit" value="Login" id="login" />
</form>
<script language="JavaScript">
   alert(document.getElementById('username').value);
</script>

Sadly, it's null. This is a problem because I want to do this:

<form>
  <input type="text" name="username" value="" onkeyup="validate();" />
  <input type="text" name="password" value="" onkeyup="validate();" />
  <input type="submit" value="Login" id="login" />
</form>
<script language="JavaScript">
   if (document.getElementById('username').value == "" && document.getElementById('password').value == "") {
    document.getElementById('login').disabled=true; }
</script>

And the validate() function would enable the button when the form fields have been filled in. The problem is that since autofill doesn't update the DOM, JS doesn't have good information.

Reproducible: Always

Comment 1

12 years ago
Firefox's password manager (in Firefox 1.5.0.7) doesn't fill in the password until the page finishes loading.  Your script is inline, so it executes well before the page finishes loading.  Try running the script onload instead, or updating to Firefox 2.

*** This bug has been marked as a duplicate of 221634 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.