I don't want to ask this easy question but i am loosing hours and I want to get it done..
businesAddressFields.get(TELEPHONE).addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent arg0) {
String telephones[] = businesAddressFields.get(TELEPHONE).getText().split(Pattern.quote(" OR "));
for (String telephone : telephones) {
if (telephone.length()>0) {
if (!telephone.matches(TELEPHONE_PATTERN)) {
showMessage("Fehler: Telephonnummer: " + telephone + " ist nicht gültig!/nMeherer Adressen mit ' OR ' trennen.", JOptionPane.ERROR_MESSAGE);
businesAddressFields.get(TELEPHONE).requestFocusInWindow();
}
}
}
@Override
public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub
}
});
I want to remove for String (telephone:telephones)
and I need to make it only telephone because i don't have array.
I want to remove Patter "OR" because i have only one phone number.
Can somebody help me with example or with code edit for me i will be very thankful..
Modify your code as follows:
public void focusLost(FocusEvent arg0) {
String telephone = businesAddressFields.get(TELEPHONE).getText());
if (telephone.length()>0) {
if (!telephone.matches(TELEPHONE_PATTERN)) {
showMessage("Fehler: Telephonnummer: " + telephone + " ist nicht gültig!/nMeherer Adressen mit ' OR ' trennen.", JOptionPane.ERROR_MESSAGE);
businesAddressFields.get(TELEPHONE).requestFocusInWindow();
}
}
}