Hi i want to make a validation on phone fields of Account. The requirement is that the phone number should not contain any letters. It should contain only numbers and symbols like ( ) - , . / \ ... What is the way to achieve this ? Thanks


You can use REGEX expression that will check your field value:

private Boolean isValid(String phone) {
    return Pattern.matches('[0-9(),./\\-]+', phone);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.