how to use jquery for validation

how to use jquery for validation

I have a question on this jquery.  I found it on login on virginatlantic.com flying club.   The site is in Adobe AEM java CMS.
How does it work in a secure environment for example, to use Jquery as a login mechanism?  What is the interstitial?  Does that mean once it validated by front end it gets handed over to another mechanism in Java to do the backend verification?  It checks the login first name and last name and email address once that is validated?  Why does it hide the error list?  It stores the username and password in localstorage but what is the referrer page for? So the referrer would be to the actual member site once the backend interstitial code gets completed?  I was just trying to figure out the mechanism to use it elsewhere.

function validateStandaloneLoginForm() {
    $(".fclStandaloneForm").validate({
        onfocusout: function(a) {
            if ($(a).valid(), "usernm_LoginPage" == a.id) {
                $("#usernm_LoginPage").val($("#usernm_LoginPage").val().trim());
                var b = $("#usernm_LoginPage").val();
                isEmailAddress(b) ? $("#lastNameField").removeClass("noDisplay") : ($("#lastNameField").addClass("noDisplay"), $("#lastnm_LoginPage").val(""))
            }
        },
        errorElement: "span",
        rules: {
            username: {
                required: !0,
                minmaxforFCNumber: !0
            },
            password: {
                required: !0,
                checkPasswordRules: !0
            },
            lastname: {
                required: !0,
                isValidName: !0,
                maxlength: 30
            }
        },
        messages: {
            username: {
                required: "Please enter your email address or Flying Club number",
                minmaxforFCNumber: "Sorry, that Flying Club number doesn't look correct - please try again. Your Flying Club number should be either 10 or 11 digits long."
            },
            password: {
                required: "Please enter your password"
            },
            lastname: {
                required: "Please enter your last name",
                isValidName: "Please enter your last name"
            }
        }
    })
}
$(document).ready(function() {
    jQuery.validator.setDefaults({
        success: "valid"
    }), hideErrorList(), validateStandaloneLoginForm(), $(document).on("click", ".fclStandaloneLoginButton", function() {
        if ($(".fclStandaloneForm").valid()) interstitialLoader("#fcStandaloneLoginPageLoader", "Loading", "medium", !0), "" === document.referrer || "undefined" == typeof document.referrer || document.referrer.match("custlogin") || $(".refreshURL").val(document.referrer.match("air-shopping") || location.href.match("widgetNav") ? document.referrer + "?" + location.href.split("?")[1] : document.referrer), $("#rememberme_LoginPage").prop("checked") ? ($(".rememberMe").val(!0), localStorage.setItem("username", $("#usernm_LoginPage").val()), localStorage.setItem("lastname", $("#lastnm_LoginPage").val())) : ($(".rememberMe").val(!1), localStorage.removeItem("username"), localStorage.removeItem("lastname"));
        else {
            var a = $(".fclStandaloneForm").validate().errorList;
            setTimeout(function() {
                showFormErrorFieldsList("#fclsaErrorWrapper", a)
            }, 500)
        }
    }), $(document).on("click", ".fclDetailsContainer .linkButton", function() {
        interstitialLoader("#fcStandaloneLoginPageLoader", "Loading", "medium", !0)
    }), document.documentMode && $("span.vaTooltip button").css("position", "relative"), $(".ui-dialog").length && $("#fcStandaloneLoginPageLoader").empty().dialog("destroy")
}), $(document).on("keyup", "#usernm_LoginPage, #pwd_LoginPage", function() {
    "" !== $("#usernm_LoginPage").val() && "" !== $("#pwd_LoginPage").val() ? $(this).valid() && ($(".fclStandaloneForm .icon").removeClass("noDisplay").addClass("displayInlineBlock"), hideErrorList()) : $(".fclStandaloneForm .icon").addClass("noDisplay").removeClass("displayInlineBlock")
});