Closed Bug 357054 Opened 18 years ago Closed 18 years ago

javascript DOM.value doesn't have autofill information

Categories

(Firefox :: General, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 221634

People

(Reporter: jon, Unassigned)

Details

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
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
Closed: 18 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.