I have tried using this code snippet for email validation but it doesnt seem to work or show any validations.
EmailAddressEditField email=new EmailAddressEditField("Email Address: ", "");
String address =email.getText();
int at = address.indexOf("@");
int len = address.length();
String host = address.substring(at + 1, len);
int dot = host.lastIndexOf('.');
len = host.length();
if (at <= 0 || at > len - 6 && dot < 0 || dot >= len - 3)
Dialog.alert("Invalid email");
else
{
if (host.indexOf("..") >= 0)
{
Dialog.alert("Invalid email");
}
else
{
//correct mail id.. continue your process
}
}
After i add(email); it gives me a dialog error of invalid email as soon as the form is opened.Please suggest me a proper email validation for a textfield/emailaddresseditfield which shows validation as soon as wrong input is typed in the field.Thanks
NOTE: The above code was taken from a previous query of similar pattern from stackoverflow.http://stackoverflow.com/questions/7580257/validation-for-email-in-blackberry Do not suggest any redirects to that same answer.Thanks.