Mozilla autocomplete bug

I recently came across an annoying little bug which seems to affect all Mozilla based browsers, including the current version (1.07) of Firefox. It seems to happen when you have a form text input field and you're using Javascript to validate whether the user has entered anything into that input field. So, for instance if you had a text input field like this:

<input type="text" name="name" value="" />

And then you had some Javascript validation on the field like this:

if (document.forms[0].elements['name'].value == '') {
   document.forms[0].elements['name'].focus();
   alert("You did not specify the name.");
   return false;
}

You would get this exception error in your Javascript console:

"Permission denied to get property XULElement.selectedIndex when calling method: [nsIAutoCompletePopup::selectedIndex]"

It seems to occur whenever you try to force focus (via Javascript) on a text input field with the "autocomplete" attribute switched on, which is the default. Mozilla have acknowledged this as a low priority bug and presumably there's a fix sometime in the future. The interim solution is to explicitly disable "autocomplete" when defining the text input field:

<input type="text" name="name" value="" autocomplete="off" />

Due to the large volume of spam, comments are disabled. If you have anything relevant to say, you can leave a , or contact me directly.

About the author

Ivan's mugshotI'm Ivan Lutrov and I'm the owner of Lutrov Interactive. I have 25 years of experience producing interactive work and I create cost effective business websites that are simple, engaging and easy to use. I practice what I preach and I say what I really think, even if it's sometimes not what you want to hear. Subscribe to the Lutrov Interactive feed via RSS and follow me on Twitter.