             emailField.resignFirstResponder()
             usernameField.resignFirstResponder()
             passwordField.resignFirstResponder()
-
-            let email = emailField.text
-            let username = usernameField.text
-            let password = passwordField.text
 
             let joinAborted: () -> Void = {
                 self.view.userInteractionEnabled = true

        })
    }

    private func validateUsername(text: String) -> Bool {
        if text.isEmpty {
            self.hideMessageLabel()
            let msg = NSLocalizedString("Username is required.", comment: "username is required message")
            self.showErrorLabel(msg)
            return false
        }
        else {
            return true
        }
    }

    private func validatePassword(text: String) -> Bool {
        if text.isValidPassword() {
            self.hideErrorLabel()
            return true
        }
        else {
            let msg = NSLocalizedString("Password must be at least 8\ncharacters long.", comment: "password length error message")
            self.showErrorLabel(msg)
            return false
        }
    }


            }
        }
        else {
            if let msg = emailErrorMessage(email) {
                self.showErrorLabel(msg)
            }
            else if let msg = usernameErrorMessage(username) {
                self.showErrorLabel(msg)
            }
            else if let msg = passwordErrorMessage(email) {
                self.showErrorLabel(msg)
            }

            Tracker.sharedTracker.joinInvalid()
        }
    }
