on 11-16-2007 5:07 AM
Hi
I have created form in Webdynpro ,which will accept input values from the user .There is one input field which takes the email address of the user .How do i validate this input field as it should only take in the input of the pattern someone@domain.com,if anyother format is entered it should give an error saying it invalid format.
Thanks and Regards
Nishita
hi,
You can use the following code:
public boolean validateEmailId( java.lang.String emailId )
{
//@@begin validateEmailId()
java.util.regex.Pattern pattern;
String value = null;
boolean isValid = false;
try {
value = emailId.toString();
pattern = java.util.regex.Pattern.compile(expression);
isValid = pattern.matcher(value).matches();
} catch (Exception e) {
}
return isValid;
//@@end
}
And expression you can define in others coding part as:
static final String expression = "(
s|>|^)(?!(:|www
.|
.))[A-Za-z0-9_.-]@([A-Za-z0-9_-]
.)+[A-Za-z]{2,4}(
s|
W|_|<|$)";
Pass your email string to this method.
thanks & regards,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All
I could check the field and it is working properly.Thank you so much.
Thanks and Regards
Nishita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can check the context of type String binded to your input field for email address as follow:
wdContext.currentContextElement().get<attribute>().matches("[A-Z0-9._%+-]@[A-Z0-9.-].");
Regards,
Murtuza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try {
Pattern p=null;
p=Pattern.compile(".@.
.[a-z]+");
Matcher m=p.matcher(name);
if(m.matches())
return true;
else
return false;
} catch (Exception e) {
return false;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.