Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TeacherCode
- private void setupListenersForValidation() {
- this.idTextField.textProperty().addListener((observable, oldValue, newValue) -> {
- if (newValue != null) {
- if (!newValue.matches("\\d{0,3}|(\\d{3}(-\\d{0,2}|-\\d{2}-\\d{0,4}))")) {
- CourseGuiCodeBehind.this.idTextField.setText(oldValue);
- CourseGuiCodeBehind.this.idErrorLabel.setVisible(true);
- } else {
- CourseGuiCodeBehind.this.idErrorLabel.setVisible(false);
- }
- }
- });
- #MyCode
- private void setupListenersForValidation() {
- this.phoneNumberTextField.textProperty().addListener((observable, oldValue, newValue) -> {
- if (newValue != null) {
- if (!newValue.matches("^\\(\\d{3}\\)\\d{3}-\\d{4}")) {
- ContactGuiCodeBehind.this.phoneNumberTextField.setText(oldValue);
- ContactGuiCodeBehind.this.idErrorLabel.setVisible(true);
- } else {
- ContactGuiCodeBehind.this.phoneNumberTextField.setText(newValue);
- ContactGuiCodeBehind.this.idErrorLabel.setVisible(false);
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement