07-03-2009 09:56 AM
Hi,
I have made code in which i am sharing my data to the address book contacts,in which the contacts which having the email address stored.
Now i want to put validation on the email address.
For example 1 contact having the email as : abc@domain.com .
How should i check that the email which is mentioned here is valid ? coz in this case so many possibility will come.
please let me know in RIM api any interface or class available which satisfy my need of validation of Email address.?
Please give any code or useful link or any Api ,which would be appreciated.
Thanks,
Mishal Shah
Solved! Go to Solution.
07-03-2009 10:06 AM
07-03-2009 11:49 AM
I should agree with simon.. But the comment I would like to make here is, it is enough to check if it is the valid format - There is no meaning in checking if it is an existing one - User will give his own email address if it is really needed..
Cheers..
07-04-2009 02:35 AM
Hi,
Thansk for valuable help.
i am not going to use any third party toll or API for the Email address validation.
Now i want any examples for the EmailAddressEditField which do the FILTER_EMAIL.
i.e. abc@info.com In this i want to check all the possiblity of validation using EmailAddressEditField or BasicEditField ,whether the given address is correct or not and after that i wanted to send on that.
Hoping that i have explained it properly.
Please give any code snippet or Useful link for the same.
Thanks,
Mishal Shah
02-07-2012 07:39 PM - edited 02-07-2012 07:39 PM
Just for anyone who is wondering the same thing, this is how I solved it and it seems to work well. You're more than welcome to elaborate on it.
signupButton = new ButtonField("Sign up", ButtonField.CONSUME_CLICK);
FieldChangeListener signupButtonLis = new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
//check email
String email = emailField.getText();
if (email.length() != 0)
{
int pos = email.indexOf("@");
if (pos != -1 && pos != 0 && email.indexOf(".", pos) != -1)
{
//email is valid
//check password
if (passwordField.getText().length() > 0)
{
if ( passwordField.getText().equals(passwordConfirmFiel d.getText()))
{
//all is good, send signup data
}
else
{
//OR passwords don't match
emailResultsField.deleteAll();
passwordResultsField.deleteAll();
passwordResultsField.add(new ColorLabelField("Password don't match!", Color.RED));
}
}
else
{
//passwordfield is empty
emailResultsField.deleteAll();
passwordResultsField.deleteAll();
passwordResultsField.add(new ColorLabelField("Password cannot be empty!", Color.RED));
}
}
else
{
//email is invalid
passwordResultsField.deleteAll();
emailResultsField.deleteAll();
emailResultsField.add(new ColorLabelField("Email is invalid!", Color.RED));
}
}
else
{
//emailfield is empty
passwordResultsField.deleteAll();
emailResultsField.deleteAll();
emailResultsField.add(new ColorLabelField("Email cannot be empty!", Color.RED));
}
}
};
signupButton.setChangeListener(signupButtonLis);