public void register() {
        if (!isStringValid(loginField.getText())) {
            loginField.setStyle("-fx-background: rgb(255,0,0);");
            errorLabel.textProperty().setValue("Логин не должен содержать русских букв!");
            errorLabel.visibleProperty().setValue(true);
            return;
        }
        else {
            loginField.setStyle("");
            errorLabel.visibleProperty().setValue(false);
        }

        if (!isStringValid(passwordField.getText())) {
            passwordField.setStyle("-fx-background: rgb(255,0,0);");
            errorLabel.textProperty().setValue("Пароль не должен содержать русских букв!");
            errorLabel.visibleProperty().setValue(true);
            return;
        }
        else {
            passwordField.setStyle("");
            errorLabel.visibleProperty().setValue(false);
        }

        if (!isStringValid(passConfirmField.getText())) {
            passConfirmField.setStyle("-fx-background: rgb(255,0,0);");
            errorLabel.textProperty().setValue("Пароль не должен содержать русских букв!");
            errorLabel.visibleProperty().setValue(true);
            return;
        }
        else {
            passConfirmField.setStyle("");
            errorLabel.visibleProperty().setValue(false);
        }

        if (!(passwordField.getText().equals(passConfirmField.getText()))) {
            passwordField.setStyle("-fx-background: rgb(255,0,0);");
            passConfirmField.setStyle("-fx-background: rgb(255,0,0);");
            errorLabel.textProperty().setValue("Пароли не совпадают!");
            errorLabel.visibleProperty().setValue(true);
            return;
        }
        else {
            passwordField.setStyle("");
            passConfirmField.setStyle("");
            errorLabel.visibleProperty().setValue(false);
        }

        UserDTO newUser = new UserDTO();
        newUser.setLogin(loginField.getText());
        newUser.setPass(passwordField.getText());
        newUser.setAdmin(false);
        newUser.setName(nameField.getText());
        if (!surnameField.getText().isEmpty())
            newUser.setSurname(surnameField.getText());
        if (!secondNameField.getText().isEmpty())
            newUser.setSecondName(secondNameField.getText());

        try {
            Factory.getInstance().getUserDAO().addUser(newUser);
        }
        catch (SQLException e) {
            System.err.println("Error while registration!");
        }

        Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                doneLabel.setVisible(true);
            }
        }), new KeyFrame(new Duration(1500), new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                myController.setScreen(Main.LoggingScreenID);
                doneLabel.setVisible(false);
                loginField.clear();
                passwordField.clear();
                passConfirmField.clear();
                nameField.clear();
                surnameField.clear();
                secondNameField.clear();
            }
        }));
        timeline.play();
    }