Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 28
Registered: ‎06-16-2009
My Device: Not Specified
Accepted Solution

How to put Email validation in Blackberry API?

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

 

 

 

Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to put Email validation in Blackberry API?

i don't know of any tool.
basically you need to check for char validaty (no forbidden chars in the string), can be done using an FILTER_EMAIL in the input field.

you can check for the @

take the domain after the @ and perform a manual DNS MX-record lookup.
i have no clue how to do that, there are many free tools available, maybe you can port one impl to the BB.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to put Email validation in Blackberry API?

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.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
New Developer
Posts: 28
Registered: ‎06-16-2009
My Device: Not Specified

Re: How to put Email validation in Blackberry API?

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

 

Highlighted
Developer
Posts: 660
Registered: ‎10-08-2009
My Device: Bold 9900
My Carrier: Telus

Re: How to put Email validation in Blackberry API?

[ Edited ]

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(passwordConfirmField.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);

 

----------------------------------------------------------
Twitter: @gyubok