Forum: Ruby on Rails Using JavaScript to validate forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
90c96b330a1e4ec7555b879b864d571c?d=identicon&s=25 Andy (Guest)
on 2006-05-19 04:21
How do i use javascript to validate the forms? What do i need to add to
<%= form_tag %> such that javascript validator function is called before
the form is submitted?

Thanks,

Andy.
90c96b330a1e4ec7555b879b864d571c?d=identicon&s=25 Andy (Guest)
on 2006-05-19 13:23
This is what i want to do; i have two models computer and problem with
1-to-Many relationship. When a user enter a new problem, he chooses the
computer where it occurred by selecting one from a list of computers. It
can happen, that the computer where the problem occurred hasn't been
registered and thus, it is not on the list yet. I add the option to
select other into computer list and add a text field to be filled when
the user selects other. The 'other computer' is going to be stored in a
model called comp_other with a 1-1 relation with problem where the FK is
stored in comp_other. Thus, i want to use javascript to check that if
the user select other from the computer list, the other text box if
filled in.
Is there a better way of doing this?

Thanks,

Andy.
This topic is locked and can not be replied to.