Simplify your business
Tuesday, 7 October 2008 1:04 pm

Mozilla autocomplete bug

Wednesday, 12 October 2005  

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" />
Posted in Development, Programming, Tips, Web by Ivan
Blinklist icon Del.iocio.us icon Furl icon Reddit icon Technorati icon Yahoo! icon

Got something to say?

To protect your privacy, your email address will not be displayed.





Some basic rules for commenting:

  • Watch your language.
  • Keep comments on-topic and relevant.
  • You can use basic XHTML tags for formatting and linking but not bbcode.
  • Comments are moderated, so don't double post if your comment doesn't appear immediately.
  • Please proof-read your comments for spelling and grammar mistakes.
  • Watch your language.