I am trying to figure out how i can check on runtime whether a number is being entered on a textfield and i want then to execute a Backspace to delete it on its own. My code is
@FXML
public void onKeyTyped(KeyEvent event) {
if (!(event.getText().matches("[a-z]"))) {
event.consume();
}
}
I dont understand why it's not working. Maybe i dont understand the concept of changing something on runtime. Any input is greatly appreciated!