bram.vandersype-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-18 12:29 UTC
element has no properties error.
Hey all, I''ve recently started messing around with Prototype again, so I thought I''d start small and write 5 lines of code that would check if all fields in a form are filled out. So I thought document.observe(''dom:loaded'', function() { $(''submNewUser'').disable(); new Form.Observer($(''newUser''), 0.3, function(e, val) { if(!$F(''newUsername'').blank() && !$F(''email'').blank() && $F(''pword'') == $F(''checkPassword'')) { $(''submNewUser'').enable(); } }); }); would do the trick. But this throws an error: element has no properties var method = element.tagName.toLowerCase(); I''m guessing it has something to do with the fact that I''m checking the value of an empty field, but I thought you had to use the blank function for it... So is this a bug or am I missing something stupid? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi,> I''m guessing it has something to do with the fact that I''m checking > the value of an empty field...That shouldn''t be a problem. Have you tried breaking up that if statement into separate checks and then walking through with a debugger like Firebug to see where exactly the error occurs? That could well reveal the problem. "element has no properties" *usually* means you''ve gotten a name wrong (case sensitivity?), or -- since we''re dealing with a form here -- that you''re trying to retrieve something by ID that doesn''t have an ID (even though it has a name). That''s an easy mistake to make. $F requires an *ID*, not a name: http://www.prototypejs.org/api/form/element/getValue Hope this helps, -- T.J. Crowder tj / crowder software / com On Apr 18, 1:29 pm, "bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey all, > > I''ve recently started messing around with Prototype again, so I > thought I''d start small and write 5 lines of code that would check if > all fields in a form are filled out. So I thought > > document.observe(''dom:loaded'', function() { > $(''submNewUser'').disable(); > new Form.Observer($(''newUser''), 0.3, function(e, val) { > if(!$F(''newUsername'').blank() && !$F(''email'').blank() && $F(''pword'') > == $F(''checkPassword'')) { > $(''submNewUser'').enable(); > } > }); > > }); > > would do the trick. But this throws an error: > element has no properties > var method = element.tagName.toLowerCase(); > > I''m guessing it has something to do with the fact that I''m checking > the value of an empty field, but I thought you had to use the blank > function for it... So is this a bug or am I missing something stupid?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---