/*========================================================================================= File Name: auth-login.js Description: Auth login js file. ---------------------------------------------------------------------------------------- Author: ACTOVISION Author URL: https://actovision.com ==========================================================================================*/ $(function () { "use strict"; //Remove localstroge items localStorage.removeItem("OnLoadToast"); var pageLoginForm = $(".auth-login-form"); // jQuery Validation // -------------------------------------------------------------------- if (pageLoginForm.length) { pageLoginForm.validate({ /* * ? To enable validation onkeyup onkeyup: function (element) { $(element).valid(); },*/ /* * ? To enable validation on focusout onfocusout: function (element) { $(element).valid(); }, */ rules: { username: { required: true, }, user_password: { required: true, }, }, submitHandler: function (form) { $.ajax({ type: "POST", url: "/api/auth_login", dataType: "json", data: $(form).serialize(), beforeSend: function () { $("button[type=button]").addClass("disabled"); Swal.fire({ title: "Please wait...", html: "We are validating your account.", allowEscapeKey: false, allowOutsideClick: false, didOpen: () => { Swal.showLoading(); }, }); }, success: function (response) { console.log(response); if (response.status == 1) { window.location.href = response.data["redirect_to"]; console.log(response); } //else if (response.status == 3) { // window.location.href = response.data['redirect_to']; // console.log(response); //} else { // console.log('ddd'); Swal.fire({ title: "Error " + response.responseCode + "!", text: response.message, icon: "error", customClass: { confirmButton: "btn btn-primary", }, buttonsStyling: false, }); } }, }); return false; // required to block normal submit since you used ajax }, }); } $("span[toggle-password=true]").click(function () { const inputField = $(this).parent().find("input"); const i = $(this).find("i"); if ($(inputField).attr("type") == "password") { $(inputField).attr("type", "text"); i.removeClass("ki-eye-slash"); i.addClass("ki-eye"); } else { $(inputField).attr("type", "password"); i.removeClass("ki-eye"); i.addClass("ki-eye-slash"); } }); });