/*========================================================================================= 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 pageSupportForm = $('.support-login-form'); // jQuery Validation // -------------------------------------------------------------------- if (pageSupportForm.length) { pageSupportForm.validate({ /* * ? To enable validation onkeyup onkeyup: function (element) { $(element).valid(); },*/ /* * ? To enable validation on focusout onfocusout: function (element) { $(element).valid(); }, */ rules: { 'user_email': { required: true, email: true }, 'loginSecret': { required: true } }, submitHandler: function (form) { $.ajax({ type: "POST", url: "/api/support_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{ 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 } }); } });