Selecting parent form

Selecting parent form

Hello,

I'm currently trying to select to parent form when I loose focus on a inputfield within that form to check the values and enable the submit button if possible. I want to keep it ass nice as possible (no hard coding). But selecting the parent form is a pain in the ass.

This is what I did:

$('input.required').blur(function()
{
      //looping over them didn't work -> however length says 2forms found what is correct
       $(this).parents().find('form').each(function test(i)
   {
      if(i==0)this.css.('background-color','red');
      else this.css.('background-color','blue');
   });

       //Nope :)---> looks like always selecting first form
      alert( $(this).parents().find('form:last'.attr('id'));
      //nothing either
      alert( $(this).parents().find('form:first').attr('id'));
}


Here is the HTML -> you see 2 forms

<form id='addForm' action='<tag:action />'>
<fieldset>
<legend>
   <tag:legend />
</legend>

<table border=0>
   <tr>
      <td colspan="2">
         <div id="manageTracklist">
          <form id='tracklistform'>
            <fieldset>
               <legend><tag:manageTracklistTitle /></legend>
               
               <table>
                  <tr>
                     <td><tag:trackArtistTitle /></td>
                     <td><input type='text' class="required" id='track_artist' name='track_artist' /></td>
                  </tr>
                  <tr>
                     <td><tag:trackTitle /></td>
                     <td><input type='text' class="required" id='track_title' name='track_title' /></td>
                  </tr>
                  <tr>
                     <td><tag:trackGenreTitle /></td>
                     <td><input type='text' id='track_genre' name='track_genre' /></td>
                  </tr>
                  <tr>
                     <td><tag:trackLengthTitle /></td>
                     <td><input type='text' id='track_length' name='track_length' /></td>
                  </tr>
                  <tr>
                     <td>&nbsp;</td>
                     <td><button id='track_submit' name='track_submit'><tag:trackSubmitTitle /></button></td>
                  </tr>
               </table>
               
               <table border=1 id='tracklistTable' style="display:none;">
                  <tr>
                     <th>#</th>
                     <th width="40" ><tag:trackArtistTitle /></th>
                     <th width="150" ><tag:trackTitle /></th>
                  </tr>
               </table>
               
            </fieldset>
            </form>
         </div>         
      </td>
   </tr>
   <tr>
      <td>&nbsp;</td>
      <td><input type='submit' value='<tag:submitText />' /></td>
   </tr>
</table>

</fieldset>
</form>


If somebody could help me Thx !