Q. How to make the input field to accept only email format of data?
A.
A.
String InputString = 'email@email.com';
String emailRegex = '([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3} \\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z ]{2,4}|[0-9]{1,3})';
Pattern MyPattern = Pattern.compile(emailRegex);
// Then instantiate a new Matcher object "MyMatcher"
Matcher MyMatcher = MyPattern.matcher(InputString);
if (!MyMatcher.matches()) {
// invalid, do something
}
Refer:
Using Regular Expressions in SFDC
No comments:
Post a Comment