Re: Bug on Form.Observer

bram.vandersype-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Thu, 03 Jan 2008 10:51:49 -0000

Issue is solved. The script disabled the button (wether it was
allready disabled or not), but this also causes to blur any field you
were in/on...
Issue solved with:
document.observe(''dom:loaded'', function() {
	new Form.Observer($(''frmLogin''), 0.3, function() {
		if($F(''txtEmail'') != '''' &&
$F(''txtPassword'') != '''') {
			$(''submLogin'').enable();
		} else
if(!$(''submLogin'').hasAttribute(''disabled''))
{
			$(''submLogin'').disable();
			if($F(''txtEmail'') == '''') {
				$(''txtEmail'').focus();
			} else {
				$(''txtPassword'').focus();
			}
		}
	});
});

The last if makes sure the empty field is focussed again, else you
could go back in browser history when holding backspace for example.
Also, autocomplete="off" could be removed now.

On Jan 3, 11:42 am,
"bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> Okay, I found out (thank you google) that the bug had something to do
> with Firefox''s Autocomplete function. By adding
autocomplete="off" in
> the field the bug is fixed. However, the input field is still
> blurred approx every 0.3 seconds (the interval I set I''m guessing)
and
> indeed, when I remove the code from the Form.Observer code, it
doesn''t
> blur anymore.
>
> I''m guessing it''s got something to do with how
I''m checking against
> empty fields???
>
> Any help would be great, thanks.
>
> On Jan 3, 1:39 am,
"bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
>
> <bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > I was trying something in Prototype (i''m brand new to it) and
mucked
> > up this:
> > document.observe(''dom:loaded'', function() {
> >         new Form.Observer(''frmLogin'', 0.3,
function() {
> >                 if($F(''txtEmail'') !=
'''' && $F(''txtPassword'') !=
'''') {
> >                         $(''submLogin'').enable();
> >                 } else {
> >                         $(''submLogin'').disable();
> >                 }
> >         });
>
> > });
>
> > now when trying it out live: i got following error in Firebug:
> > [Exception... "''Geen toestemming om eigenschap
> > XULElement.selectedIndex te wijzigen'' when calling method:
> > [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e
> > (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame
::http://localhost/libs/js/prototype.js::anonymous :: line 3517" data:
> > no]
>
> > It''s dutch but translates as Exception... "No permission
to edit
> > property XULElement...... when calling method: "
>
> > Form.EventObserver works great, but it''s a login field, so
I''d want to
> > be able to press enter from the password field, instead of first
> > blurring the password field...