So, guys, I have a window where I need to pass a validation of null fields of several JTextField
and a JFormattedTextField
, where the latter has a mask for phone numbers "(##)####-####"
. The fact is that even though I do not type anything in this field, it takes the characters from the mask: ()-
and understands that the field is not null. I would like to know if there is any method that ignores characters from a mask, or will I have to do all that trap with substring
? It is worth mentioning that I just want to ignore it at the time of the validation, and do not remove those characters, because then I will have to introduce them to the user!
How to instantiate:
try {
mskTel = new MaskFormatter("(##)####-####");
} catch (ParseException e) {
e.printStackTrace();
}
txtTel = new JFormattedTextField(mskTel);
How the validation is done:
form.txtTel.getText() == null || form.txtTel.getText().trim().isEmpty()