jQuery events help
<p>I have this code:</p>

<pre><code>$('form').submit(function()
{
    if (newpost_validator.numberOfInvalids() &gt; 0)
    {
        HideModal();
    }
    else
    {
        ShowModal();
    }
});
</code></pre>

<p>The idea is that it checks if an validation issues have happened when a form is submitted and if none then show a modal box. However I want to check multiple forms as this code is sitting inside a parent JS file. So for example:</p>

<pre><code>$('form').submit(function()
{
    if (newpost_validator.numberOfInvalids() &gt; 0)
    {
        HideModal();
    }
    if (newcomment_validator.numberOfInvalids() &gt; 0)
    {
        HideModal();
    }
    else
    {
        ShowModal();
    }
});
</code></pre>

<p>BUT that wouldn't work because even though newpost may be valid, the newcomment will not because it's not being used! Therefore I can't write my code this way. I thought about duplicating the function for each instance but that's not feasible either.</p>

<p>Any ideas on how I could do multiple checks on forms without confliction? I need the selector to stay as just form because some forms don't have validation and I want to make all forms show the modal on submit.</p>

<p>Thanks.</p>
