Suppose that I use Rails to create an HTML form element. By that I mean that I have some Ruby code that I call from within <%= %> and the Ruby code then generates the form element for me. So what actually gets stuck into the code might look like this: <input type="text" name="element1" /> It appears that if, on submission, I use JS to validate by checking to see if element1 is longer than 0 characters, it appears that JS thinks that element1 is undefined. Am I making some mistake; or, is that the expected result? If it is the expected result, anything I can do so as to be able to validate using JS? Thanks. ... doug --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 2, 2007, at 6:55 PM, doug wrote:> <input type="text" name="element1" /> > > It appears that if, on submission, I use JS to validate by checking > to see if element1 is longer than 0 characters, it appears that > JS thinks that element1 is undefined.You''ll need an id="element1" in there for getElementById to work. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---