Advertisement
Guest User

Coding

a guest
Apr 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #TeacherCode
  2. private void setupListenersForValidation() {
  3. this.idTextField.textProperty().addListener((observable, oldValue, newValue) -> {
  4. if (newValue != null) {
  5. if (!newValue.matches("\\d{0,3}|(\\d{3}(-\\d{0,2}|-\\d{2}-\\d{0,4}))")) {
  6. CourseGuiCodeBehind.this.idTextField.setText(oldValue);
  7. CourseGuiCodeBehind.this.idErrorLabel.setVisible(true);
  8. } else {
  9. CourseGuiCodeBehind.this.idErrorLabel.setVisible(false);
  10. }
  11. }
  12. });
  13. #MyCode
  14.  
  15. private void setupListenersForValidation() {
  16. this.phoneNumberTextField.textProperty().addListener((observable, oldValue, newValue) -> {
  17. if (newValue != null) {
  18. if (!newValue.matches("^\\(\\d{3}\\)\\d{3}-\\d{4}")) {
  19. ContactGuiCodeBehind.this.phoneNumberTextField.setText(oldValue);
  20. ContactGuiCodeBehind.this.idErrorLabel.setVisible(true);
  21. } else {
  22. ContactGuiCodeBehind.this.phoneNumberTextField.setText(newValue);
  23. ContactGuiCodeBehind.this.idErrorLabel.setVisible(false);
  24. }
  25. }
  26. });
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement