jQuery validation not working after coming back from Thickbox display

jQuery validation not working after coming back from Thickbox display

  Hi,
      I am using Thickbox 3.1, jquery-1.3.2.min.js and jquery.validate.js.

I have a form that on click presents a preview page, which is a thickbox tb_show. when i close a thick box and edit the fields, validation messages are appearing properly. But my cursor is not coming out of validator() method in the below code.

I am adding the code snippet below:

Any help or suggestion is appreciated. Thanks in advance.

Regards: Qayyum

<form class="standard" action="<%=formAction%>" method="post" name="registerCard" id="registerCard">
       
<fieldset>
           
<legend>Personal Details</legend>
           
<div>
               
<label for="firstName" >First Name</label>
               
<input name="firstName" type="text" id="firstName" value="" />
           
</div>
           
<div>
               
<label for="lastName">Last Name</label>
               
<input name="lastName" type="text" id="lastName" value="" />
           
</div>
           
<div>

               

<a id="previewDetails" href='#' class="btn std right" onclick="javascript:preview()">Preview & Register</a>
           
</div>
   
</fieldset>
</form>

var url = '<%=previewAction%>?height=500&width=720';
function preview(){
   validate
();
alert("this alert is not coming after coming back from preview");

if ($("#registerCard").valid()) {
                    url
= url + '&firstName='+escape(document.registerCard.firstName.value);
                    url
= url + '&lastName='+escape(document.registerCard.lastName.value);
 tb_show
("",url,false);
}

validate method

function validate() {
  $
('#registerCard').validate(
   
{
      rules
: {
        firstName
: {
          required
:function(){
              alert
(" in validate 3");
             
return true;
               
},
          rangelength
: [ 2, 20 ]
       
},
        lastName
: {
          required
:true,
          rangelength
: [ 2, 20 ]
       
},
        spam
:"required"
     
}, // end rules
      messages
: {
        firstName
: {
          required
:RP.I18n.getMessage("firstnamemessage"),
          rangelength
:RP.I18n.getMessage("fieldRange", [
             
"First Name", "2", "20" ])
       
},
        lastName
: {
          required
:RP.I18n.getMessage("lastnamemessage"),
          rangelength
:RP.I18n.getMessage("fieldRange", [
             
"Last Name", "2", "20" ])
       
}
     
},//end messages
      errorPlacement
: function(error, element) {
       
if (element.is(":radio") || element.is(":checkbox")) {
          error
.appendTo(element.parent());
       
} else {
          error
.insertAfter(element);
       
}
     
}
   
}); //end error placement
}

The second form. I am showing read only fields and values. I have a Edit or submit button as follow:

< a id="save" href='#' class="btn std right" onclick="javascript:register()">Save</a> 
< a href="#" onclick="tb_remove()" class="btn std right">edit
</a>

When I click on edit, it simply removes the thick box, and previous register form page appears. Now when i click preview again, after validations completed, code after the validation call is not executing, as shown in the above code with alert.

Why is it happening so?