Question : Javascript: how to validate a form when there are multiple instances on the page?

I have a page that has three forms on it. One is displayed to the user. The other two are hidden and appear in a lightbox when a link is clicked. All three instances come from the same include file.

I am unable to validate the form because JS cannot determine which form is being submitted.

How can I distinguish one from the other?

The form code must be the same but I can change the parent <DIV> container ID if needed:
<div id="form1">INCLUDE FORM FILE</div>
<div id="form2">INCLUDE FORM FILE</div>
<div id="form3">INCLUDE FORM FILE</div>

Thoughts?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
window.addEvent('domready', function()
{
    $('submit-request').addEvent('click', function( event )
    {
        if ( checkForm() )
            $( 'contactForm' ).submit();

        new Event( event ).stop();
    });
});

Answer : Javascript: how to validate a form when there are multiple instances on the page?

FYI: when you do this:
 $('th')

internally, jquery actually "executes":
 $('th', document);

that's why you would get all the th in the document.

Reference:
http://docs.jquery.com/%24
Random Solutions  
 
programming4us programming4us