Using JavaScript to validate forms

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.

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.