// ======= // Sign In // ======= $(document).ready(function () { var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ================= // Process Enter Key // ================= $(document).on('keypress', function (e) { if (e.which == 13) { e.preventDefault(); $("#signIn").submit(); } }); // ----------- // Save Button // ----------- $(".btnSignIn").on("click", function (e) { e.preventDefault(); $("#signIn").submit(); }); // --------------- // Validate Inputs // --------------- $("#signIn").submit(function (e) { var user_name = $("#user_name"), user_password = $("#user_password"); clearInputErrors(); user_name.val(user_name.val().replace(/\s+/g, " ").trim()); if (isBlank(user_name)) { createInputError(user_name, "User Name/Email is required"); return false; } if (isBlank(user_password)) { createInputError(user_password, "Password is required"); return false; } return true; }); }); // -------------------------------- // Clear the Error State for Inputs // -------------------------------- function clearInputErrors() { $(".is-invalid").removeClass("is-invalid"); $(".invalid-feedback").remove(); } // -------------------- // Test for Blank Value // -------------------- function isBlank(object) { if ($.trim(object.val()).length == 0) { return true; } else { return false; } } // ----------------------------------- // Create an Error State for an Input. // ----------------------------------- function createInputError(input, message = "", scroll = false) { if ($(input).hasClass("search-dropdown")) { // Select Picker $(input).closest(".bootstrap-select") .find(".bs-placeholder") .addClass("is-invalid") .after("