开发者

why is the pop up alert is showing twice in my app?

Do you guys have any idea why all of the alert boxes in my script are popping up twice?

They only disappear after I click the OK button from the alert box's second popup.

Here is a working example: http://jsfiddle.net/MSbXF/1/

JS

$(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 && (cvusername == "" || cvusername.length < 1 || cvusername.length > 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 < 5 || resumetitle.length > 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 <  1 || resumetitle.length > 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 < 6 ||contacttel1.length > 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 < 5 || contacttel1type.length > 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 < 6 ||contacttel2.length > 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 < 5 || contacttel2type.length > 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 < 6 ||contacttel3.length > 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 < 5 || contacttel3type.length > 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+"&cvusername="+cvusername+"&resumetitle="+resumetitle+"&resumeintro="+resumeintro+
//            "&name="+name+"&dob="+dob+"&contacttel1="+contacttel1+"&contacttel1type="+contacttel1type+
//            "&contacttel2="+contacttel2+"&contacttel2type="+contacttel2type+"&contacttel3="+contacttel3+
//            "&contacttel3type="+contacttel3type+"&primaryemail="+primaryemail+"&secondaryemail="+secondaryemail+
//            "&skype="+skype+"&facebook="+facebook+"&linkedin="+linkedin+"&twitter="+twitter+
//            "&messenger="+messenger+"&yahoo="+yahoo+"&aol="+aol+"&summaryofpositionsought="+
//            summaryofpositionsought+"&summaryofskills="+summaryofskills+"&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+"&resumetitle="+resumetitle+"&resumeintro="+resumeintro+
            "&name="+name+"&dob="+dob+"&contacttel1="+contacttel1+"&contacttel1type="+contacttel1type+
            "&contacttel2="+contacttel2+"&contacttel2type="+contacttel2type+"&contacttel3="+contacttel3+
            "&contacttel3type="+contacttel3type+"&primaryemail="+primaryemail+"&secondaryemail="+secondaryemail+
            "&skype="+skype+"&facebook="+facebook+"&linkedin="+linkedin+"&twitter="+twitter+
            "&messenger="+messenger+"&yahoo="+yahoo+"&aol="+aol+"&summaryofpositionsought="+
            summaryofpositionsought+"&summaryofskills="+summaryofskills+"&gender="+gender,
      success: function(){
           $('form#wsrecruitcvhead').fadeOut("normal",function(){
           $('div.successpost').fadeIn(1000);
        });
      },
开发者_JAVA百科      });
      return false;
        // }
      }
   });
 });


I'll post it as an answer then...

You have your javascript files included twice!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜