why is the pop up alert is showing twice in my app?
<p>Do you guys have any idea why all of the alert boxes in my script are popping up twice?</p>

<p>They only disappear after I click the <em>OK</em> button from the alert box's second popup.</p>

<p>Here is a working example: <a href="http://jsfiddle.net/MSbXF/1/" rel="nofollow">http://jsfiddle.net/MSbXF/1/</a></p>

<p><strong>JS</strong></p>

<pre><code>$(document).ready(function(){
  $('div.successpost').hide();
  $('div.errorpost').hide();
  $('div#dialog-confirm').hide();
  $('div#registerpopup').hide();
  $('div#loginpopup').hide();
  $('div#login-Block2').hide();
  $('div.successpostregister').hide();
  $("form#wsrecruitcvhead").submit(function(){
   var errorpost = $('div.errorpost');
   var successpost = $('div.successpost');

   var userid = $('input[type=hidden]').val();
   var cvusername = $('#cvusername').val();
   var resumetitle = $('#resumetitle').val()
   var resumeintro = $('#resumeintro').val();
   var name = $('#name').val();
   var dob = $('#datepicker').val();
   var contacttel1 = $('#contacttel1').val();
   var contacttel1type = $('#contacttel1type').val();
   var contacttel2 = $('#contacttel2').val();
   var contacttel2type = $('#contacttel2type').val();
   var contacttel3 = $('#contacttel3').val();
   var contacttel3type = $('#contacttel3type').val();
   var primaryemail = $('#primaryemail').val();
   var secondaryemail = $('#secondaryemail').val();
   var skype = $('#skype').val();
   var facebook = $('#facebook').val();
   var linkedin = $('#linkedin').val();
   var twitter = $('#twitter').val();
   var messenger = $('#messenger').val();
   var yahoo = $('#yahoo').val();
   var aol = $('#aol').val();
   var summaryofpositionsought = $('#summaryofpositionsought').val();
   var summaryofskills = $('#summaryofskills').val();
   var gender = jQuery("input['gender']:checked").val();


//  var username = $('#username').val();
//  var password = $('#password').val();
//  var retypepassword = $('#retypepassword').val();
//  var emailaddress = $('#emailaddress').val();
//  var secondaryemailaddress = $('#secondaryemailaddress').val();
//  var secretquestion = $('#secretquestion').val();
//  var secretanswer = $('#secretanswer').val();
//  var reffcode = $('#reffcode').val();
  var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;


     if(document.getElementById("cvusername")!== null &amp;&amp; (cvusername == "" || cvusername.length &lt; 1 || cvusername.length &gt; 30 ||  cvusername.indexOf(' ') != -1)){
        //errorpost.text("Resume Title is required").fadeIn(300).delay(1800).fadeOut(300);
        alert("-username is required\n-should not be less than 1 character\n-not greater than 30 characters\n-It may also not contain spaces");
        return false;
     }
     if(resumetitle == "" || resumetitle.length &lt; 5 || resumetitle.length &gt; 60){
        //errorpost.text("Resume Title is required").fadeIn(300).delay(1800).fadeOut(300);
        alert("-Resume Title is required\n-should not be less than 5 characters\n and not greater than 60 characters");
        return false;
     }
     if(resumeintro == ""){
       // errorpost.text("Resume Summary is required").fadeIn(300).delay(900).fadeOut(300);
       alert("Resume Summary Introduction is required");
       return false;
     }
     if(name == "" || name.length &lt;  1 || resumetitle.length &gt; 50){
       // errorpost.text("Name is required").fadeIn(300).delay(900).fadeOut(300);
       alert("Name is required\n-should not be less than 1 characters\nand not more than 50 characters");
       return false;
     }
     if(dob == ""){
       // errorpost.text("Date of birth is required").fadeIn(300).delay(900).fadeOut(300);
       alert("Date of birth is required");
       return false;
     }
     if(contacttel1 == "" || isNaN(contacttel1) || contacttel1.length &lt; 6 ||contacttel1.length &gt; 30){
       // errorpost.text("Contact Tel1 is required").fadeIn(300).delay(900).fadeOut(300);
       alert("Contact tel1 is required\n-should be numeric only\n-should be more than 6 characters\n-not more than 30 digits");
       return false;
     }
     if(contacttel1type == "" || contacttel1type.length &lt; 5 || contacttel1type.length &gt; 50){
       // errorpost.text("Contact Tel1 Type is required").fadeIn(300).delay(900).fadeOut(300);
       alert("Contact Tel1 type is required\n-should not be lower 5 characters\n-should not exceed 50 characters");
       return false;
     }
//     if(contacttel2 == "" || isNaN(contacttel2) || contacttel2.length &lt; 6 ||contacttel2.length &gt; 30){
//       alert("Contact tel2 is required\n-should be numeric only\n-should be more than 6 characters\n-not more than 30 digits");
//       return false;
//     }
//     if(contacttel2type == "" || contacttel2type.length &lt; 5 || contacttel2type.length &gt; 50){
//       alert("Contact Tel2 type is required\n-should not be lower 5 characters\n-should not exceed 50 characters");
//       return false;
//     }
//     if(contacttel3 == "" || isNaN(contacttel3) || contacttel3.length &lt; 6 ||contacttel3.length &gt; 30){
//       alert("Contact tel3 is required\n-should be numeric only\n-should be more than 6 characters\n-not more than 30 digits");
//       return false;
//     }
//     if(contacttel3type == "" || contacttel3type.length &lt; 5 || contacttel3type.length &gt; 50){
//       alert("Contact Tel3 type is required\n-should not be lower 5 characters\n-should not exceed 50 characters");
//       return false;
//     }
     if(primaryemail == "" || primaryemail.search(emailRegEx) == -1){
       // errorpost.text("Primary Email is required").fadeIn(300).delay(900).fadeOut(300);
       alert("Primary Email is required\nand it should be a valid email address");
       return false;
     }
//     if(secondaryemail == ""){
//       // errorpost.text("Secondary Email is required").fadeIn(300).delay(900).fadeOut(300);
//       alert("Secondary Email is required");
//       return false;
//      }



     if(userid == ""){
        $( "#dialog:ui-dialog" ).dialog( "destroy" );

        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height: 230,
            width: 350,
            modal: true,
            buttons: {
                "Register": function(){
                    $(this).dialog("close");
                    $('div#registerpopup').dialog({
                       resizable: false,
                       height: 600,
                       width: 600,
                       modal: true,
                    })
                },
                "Log in": function() {
                    $(this).dialog("close");
                    $('div#loginpopup').dialog({
                      resizable: false,
                      height: 230,
                      width: 350,
                      modal: true
                    })
                }
            }
        });
        return false;
     }

   else {
//    if(userid == ""){
//   $.ajax({
//      type: "POST",
//      url: "classes/ajax.submitcv.php",
//      timeout: 8000,
//      data: "userid="+userid+"&amp;cvusername="+cvusername+"&amp;resumetitle="+resumetitle+"&amp;resumeintro="+resumeintro+
//            "&amp;name="+name+"&amp;dob="+dob+"&amp;contacttel1="+contacttel1+"&amp;contacttel1type="+contacttel1type+
//            "&amp;contacttel2="+contacttel2+"&amp;contacttel2type="+contacttel2type+"&amp;contacttel3="+contacttel3+
//            "&amp;contacttel3type="+contacttel3type+"&amp;primaryemail="+primaryemail+"&amp;secondaryemail="+secondaryemail+
//            "&amp;skype="+skype+"&amp;facebook="+facebook+"&amp;linkedin="+linkedin+"&amp;twitter="+twitter+
//            "&amp;messenger="+messenger+"&amp;yahoo="+yahoo+"&amp;aol="+aol+"&amp;summaryofpositionsought="+
//            summaryofpositionsought+"&amp;summaryofskills="+summaryofskills+"&amp;gender="+gender,
//      success: function(){
//           $('form#wsrecruitcvhead').fadeOut("normal",function(){
//           $('div.successpostregister').fadeIn(1000);
//        });
//      },
//      });
//      return false;
//     } else {

   $.ajax({
      type: "POST",
      url: "classes/ajax.submitcv.php",
      timeout: 8000,
      data: "userid="+userid+"$cvusername="+cvusername+"&amp;resumetitle="+resumetitle+"&amp;resumeintro="+resumeintro+
            "&amp;name="+name+"&amp;dob="+dob+"&amp;contacttel1="+contacttel1+"&amp;contacttel1type="+contacttel1type+
            "&amp;contacttel2="+contacttel2+"&amp;contacttel2type="+contacttel2type+"&amp;contacttel3="+contacttel3+
            "&amp;contacttel3type="+contacttel3type+"&amp;primaryemail="+primaryemail+"&amp;secondaryemail="+secondaryemail+
            "&amp;skype="+skype+"&amp;facebook="+facebook+"&amp;linkedin="+linkedin+"&amp;twitter="+twitter+
            "&amp;messenger="+messenger+"&amp;yahoo="+yahoo+"&amp;aol="+aol+"&amp;summaryofpositionsought="+
            summaryofpositionsought+"&amp;summaryofskills="+summaryofskills+"&amp;gender="+gender,
      success: function(){
           $('form#wsrecruitcvhead').fadeOut("normal",function(){
           $('div.successpost').fadeIn(1000);
        });
      },
      });
      return false;
        // }
      }
   });
 });
</code></pre>
