function validateCurrentPage()

in tree/master/cloud/src/solution/Microsoft.Legal.MatterCenter.Web/wwwroot/app/matter/createMatter.controller.js [2830:3034]


            function validateCurrentPage(iCurrPage) {
                if (iCurrPage == 1) {

                    var windowWidth = GetWidth();
                    var RegularExpressionForMatterName, RegularExpressionForMatterID;
                    if (undefined !== cm.selectedClientName && null !== cm.selectedClientName && "" !== cm.selectedClientName.trim()) {                       
                        if (cm.canCreateMatterPermission) {
                            if ("" !== cm.clientId.trim() && null !== cm.clientId) {
                                var bInValid = false;
                                RegularExpressionForMatterName = new RegExp(specialCharactersRegExp.SpecialCharacterExpressionMatterTitle);
                                var sCurrMatterName = cm.matterName.trim();
                                if (null !== sCurrMatterName && "" !== sCurrMatterName) {
                                    var arrValidMatch = sCurrMatterName.match(RegularExpressionForMatterName);
                                    if (null === arrValidMatch || arrValidMatch[0] !== sCurrMatterName) {
                                        bInValid = false;
                                    } else {
                                        bInValid = true;
                                    }
                                }
                                if (bInValid) {
                                    oPageOneState.isNextClick = true;
                                    if (undefined !== oPageOneState.oValidMatterName) {
                                        if (oPageOneState.oValidMatterName) {
                                            bInValid = false;
                                            var sCurrentMatterId = cm.matterId;
                                            RegularExpressionForMatterID = new RegExp(specialCharactersRegExp.SpecialCharacterExpressionMatterId);
                                            if (undefined !== sCurrentMatterId && null !== sCurrentMatterId && "" !== sCurrentMatterId) {
                                                sCurrentMatterId = sCurrentMatterId.trim();
                                                var arrValidMatch = sCurrentMatterId.match(RegularExpressionForMatterID);
                                                if (null === arrValidMatch || arrValidMatch[0] !== sCurrentMatterId) {
                                                    bInValid = false;
                                                } else {
                                                    bInValid = true;
                                                }
                                            }
                                            else {
                                                cm.errTextMsg = cm.createContent.ErrorMessageEntityId1;
                                                //"Enter a matter ID.";
                                                cm.errorBorder = "matterid";
                                                showErrorNotification("matterid");
                                                cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                                            }
                                            if (bInValid) {
                                                if (cm.isMatterDescriptionMandatory) {
                                                    var sCurrentMatterDesc = cm.matterDescription;
                                                    bInValid= matterDescriptionValidation(sCurrentMatterDesc);
                                                }
                                                else {
                                                    if (cm.matterDescription != "") {
                                                        var sCurrentMatterDesc = cm.matterDescription;
                                                        bInValid = matterDescriptionValidation(sCurrentMatterDesc);
                                                    } else {
                                                        bInValid = true;
                                                    }
                                                }
                                                if (bInValid) {
                                                    if (cm.selectedDocumentTypeLawTerms.length > 0) {
                                                        storeMatterDataToLocalStorageFirstPage();
                                                        return true;
                                                    }
                                                    else {
                                                        cm.errTextMsg = cm.createContent.ErrorMessageSelectType;
                                                        //"Select matter type by area of law for this matter";
                                                        cm.errorBorder = ""; showErrorNotification("selecttemp");
                                                        cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                                                    }
                                                }
                                                else {
                                                    // alert("Enter a description for this matter");
                                                    cm.errTextMsg = cm.createContent.ErrorMessageSpecialCharacters;
                                                    //"Please enter a valid text which contains only alphanumeric characters, spaces & hyphen";
                                                    showErrorNotification("matterdescription");
                                                    cm.errorBorder = "matterdescription";
                                                    cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                                                }
                                            }
                                            else {
                                                cm.errTextMsg = cm.createContent.ErrorMessageSpecialCharacters;
                                                //"Please enter a valid text which contains only alphanumeric characters, spaces & hyphen.";
                                                cm.errorBorder = "matterid";
                                                showErrorNotification("matterid");
                                                cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                                            }
                                        }
                                        else {
                                            cm.errTextMsg = cm.createContent.ErrorMessageEntityLibraryCreated;
                                            //"Matter library for this Matter is already created. Kindly delete the library or please enter a different Matter name.";
                                            cm.errorBorder = "mattername";
                                            showErrorNotification("mattername");
                                            cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                                        }
                                    }
                                }
                                else {
                                    cm.errTextMsg = cm.createContent.ErrorMessageEntityNameSpecialCharacters;
                                    //"Please enter a valid Matter name which contains only alphanumeric characters and spaces";
                                    cm.errorBorder = "mattername";
                                    showErrorNotification("mattername");
                                    cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                                }
                            }
                            else {
                                cm.errTextMsg = cm.createContent.ErrorMessageEntityId2;
                                //"Selected  client for this matter clientId is null ";
                                showErrorNotification("client");
                                cm.errorBorder = "client";
                                cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                            }
                        }
                        else {
                            cm.errTextMsg = cm.errPermissionMessage;
                            //"Selected  client for this matter clientId is null ";
                            showErrorNotification("client");
                            cm.errorBorder = "client";
                            cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                        }
                    }
                    else {
                        cm.errTextMsg = cm.createContent.ErrorMessageEntityTeamOrClient1;
                        //"Select a client for this matter ";
                        cm.errorBorder = "client";
                        showErrorNotification("client");
                        cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500);
                        return false;
                    }
                }
                else if (iCurrPage == 2) {
                    cm.blockedUserName = cm.conflictUsers.assignedUser;
                    if (cm.defaultConfilctCheck) {
                        if (undefined !== cm.chkConfilctCheck && true == cm.chkConfilctCheck) {

                            if (undefined !== cm.conflictDate && null !== cm.conflictDate && "" != cm.conflictDate) {
                                
                                var validUsers = validateUsers();
                                var checkUserDExists = false;
                                if (validUsers) {
                                    checkUserDExists = validateCheckUserExisits();
                                    if (checkUserDExists) {
                                        var attornyCheck = validateAttornyUserRolesAndPermissins();
                                        if (attornyCheck) {
                                            cm.popupContainerBackground = "Show";
                                            storeMatterDataToLocalStorageSecondPage();
                                            cm.popupContainerBackground = "hide";
                                            return true;
                                        }
                                    }
                                }

                            }
                            else {
                                cm.errTextMsg = cm.createContent.ErrorMessageEntityDate;
                                //"Enter the date on which the conflict check was performed ";
                                cm.errorBorder = "cdate"; showErrorNotification("cdate");
                                cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500); return false;
                            }
                        }
                        else {
                            cm.errTextMsg = cm.createContent.ErrorMessageEntityConflictCheck;
                                //"A confilct check must be completed prior to provisioning this matter ";
                            cm.errorBorder = "";
                            showErrorNotification("conflictcheck");
                            cm.errorPopUpBlock = true; $timeout(function(){angular.element('#errorBlock').focus();},500);
                        }
                    } else {
                        var validUsers = validateUsers();
                        var checkUserExisits = false;
                        if (validUsers) {
                            checkUserExisits = validateCheckUserExisits();
                            if (checkUserExisits) {
                                var attornyCheck = validateAttornyUserRolesAndPermissins();
                                if (attornyCheck) {
                                    cm.popupContainerBackground = "Show";
                                    storeMatterDataToLocalStorageSecondPage();
                                    cm.popupContainerBackground = "hide";
                                    return true;
                                }
                            }
                        }
                    }
                }
                else if (iCurrPage == 4 && cm.inputs.length > 0) {
                    cm.popupContainerBackground = "Show";
                    cm.addFieldReq = false;
                    angular.forEach(cm.inputs, function (val) {
                        if (val.type.toLowerCase() != 'boolean' && val.displayInUI == "true" && val.required == "true" && (val.value == null || val.value == undefined)) {
                            cm.addFieldReq = true;
                        }
                    });
                    cm.popupContainerBackground = "hide";
                    if (cm.addFieldReq) {
                        return false;
                    }
                    storeMatterDataToLocalStorageAddtionalPage();
                    return true;
                }
                else if (iCurrPage == 3 && cm.inputs.length == 0) {
                    return true;
                }
                else if (iCurrPage == 4) {
                    return true;
                }
                else {
                    return true;
                }
            }