Tried IF ELSE with two function, does not work

Tried IF ELSE with two function, does not work

Tried combining my Jquery validate with proress animation like this, but does not work: these two functions need to work as validate is successful and all field filled, then do page animation of progress load.

[code]

          jQuery(function(){
     if(validate){
                jQuery("#oldpassword").validate({
                    expression: "if (VAL.length > 5 && VAL) return true; else return false;",
                    message: "Please enter a Current Password"
                });
                jQuery("#password").validate({
                    expression: "if (VAL.length > 5 && VAL) return true; else return false;",
                    message: "Please enter a valid New Password"
                });
                jQuery("#confirmpassword").validate({
                    expression: "if ((VAL == jQuery('#password').val()) && VAL) return true; else return false;",
                    message: "Confirm password doesn't match the new password"
                });
      
}else{
  $(document).ready(function () {
$("#loading-div-background").css({ opacity: 0.8 });
  });

 function ShowProgressAnimation() {
  $("#loading-div-background").show();
  $(".button-2").hide();
 }
     }
            });

[/code]