On Jul 19, 9:13 am, jarrod <[EMAIL PROTECTED]> wrote:
> I'm trying to write a script that responds to a keyup event in any field of a
> given form. If the form is valid, the submit button of that form is enabled.
> The problem is that there are several forms on the page. My script has to
> enable the right one.
>
> I have a way that works, but it's complicated. Can someone suggest a better
> way?

A couple of tips:

You can attach a function to the form's keyup handler, you don't have
to put it on every control in the form.

Every control in a form has a "form" attribute that is a reference to
the form that the control is in, there is no need to use any kind of
DOM-walking or parent relationship, e.g.:

  <form id="formA">
   <div>
    <button onclick="alert(this.form.id);">Show form ID</button>
   </div>
 </form>


--
Rob

Reply via email to