You need to sign in to do that
Don't have an account?

Phone number Vallidation Regex, Pattern, matcher
Hi,
I am putting one validation for 3 phone number fields in community. User can not add characters except ( ) - space and number.
Pleasse help on this. here is the sample code.
I am putting one validation for 3 phone number fields in community. User can not add characters except ( ) - space and number.
Pleasse help on this. here is the sample code.
Pattern p = Pattern.compile('(REGEX(Phone, "^(?=.*?[1-9])[0-9()-]+$"))'); Matcher otherphone; Boolean isPhoneError = false; if (newUserContact.otherphone != null && newUserContact.otherphone != ''){ otherphone = p.matcher( (string)newUserContact.otherphone); if(otherphone.matches()){ isPhoneError = true; } } if(isPhoneError) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, system.label.PhoneInvalid); ApexPages.addMessage(msg); return false; }
Please refere below link for more details
http://regexlib.com/(X(1)A(nDLmjU9Uol4BI8_ub94cgATOKekjnlf7bPpYZj6bJTMEnPllSXN0NZrDs20vanqoaSwyiCgfZxuEpevjZjyUY6gCJMC0T4XzvUYuj1o3J45JzCw7u58o5r_pr8T884YbhmTlstnT0UXkNvBm69KJAYECMU03jXhd9QC3ewX27DggD4D8s7zacfshSC22HDhs0))/Search.aspx?k=phone&c=-1&m=-1&ps=20
Thanks,
Sandeep