function update_password(){
    text_box_validation_update_password();



    const formdata = new FormData();
    formdata.append("current_password", $("#current_password").val());
    formdata.append("new_password", $('[name="new_password"]').val());
    formdata.append("confirm_password", $("#confirm_password").val());

    $.ajax({
       type:'POST',
      // enctype: 'multipart/form-data',
       url:window.location.origin+"/trainingportal/Settings/update_password",
       data: formdata,
       contentType: false,
       processData: false,
       success:function(data){
        if(data==1){
          document.getElementById("success_alert").style.display = "block";
        }else{
          document.getElementById("error_alert").style.display = "block";
        }
       }
    });

}

function password_checker(){

    if( $('[name="new_password"]').val() == $("#confirm_password").val()){
        $("#confirm_password").css({
            "border": "1px solid green",
            "background": "#B1FFCA"
        }); 
    }else{
        $("#confirm_password").css({
            "border": "1px solid red",
            "background": "#FFCECE"
        }); 
    }
}
function text_box_validation_update_password(){

    var isValid = true;
    $('#current_password,#new_password,#confirm_password').each(function () {
        if ($.trim($(this).val()) == '') {
            isValid = false;
            $(this).css({
                "border": "1px solid red",
                "background": "#FFCECE"
            });
        }
        else {
            $(this).css({
                "border": "",
                "background": ""
            });
        }
    });
    if (isValid == false){
          return;
    }
        
}

function update_profile_picture(){
    var file_data = $("#profile_picture").prop("files")[0];
    const formdata = new FormData();
    formdata.append("image_data", file_data); 
    $.ajax({
        type:'POST',
       // enctype: 'multipart/form-data',
        url:window.location.origin+"/trainingportal/Settings/update_profile_pic",
        data: formdata,
        contentType: false,
        processData: false,
        success:function(data){
         if(data==1){
       
        //  document.getElementById("module_success_alert").style.display = "block";
         }else{
       
         // document.getElementById("module_error_alert").style.display = "block";
         }
        }
     });
}
