hi ..

I want to display an error if the user didn't enter the id or the password in the Text fild.. but nothing happed when I compare it to null .. or to "" .. is there any way to do this? I also tried to compare it with constant .. but it did work as well .. any suggestions?? this is what I have..

if ( (userID.getString() == null ) || (userPW.getString() == null))
		   {
			    System.out.println("Missing required information");
			    doAlarm();

		   }
if ( (userID.getString().length() == 0 ) || (userPW.getString().length() == 0))
if ( (userID.getString().length() == 0 ) || (userPW.getString().length() == 0))

thank u .. I have done what u 've mentioned and its work well now.

but I faced other problem if u could help me..

if the data base could not find the user it should return
string response = "User Not Found"

otherwise it should return the user details .

I tried to check the return value from response but it also not work with me ..

I have written

if (response != "User Not Found")
				 {
					 menu();

				 }
				else
				 {
					 System.out.println("User Not Found,Please Make Sure from Your Login Details");
					 doAlarm();

				 }

You should be using String.equals() , or, in this case !String.equals() so, your example would then be:

if(!response.equals("User Not Found");
//blah blah, rest of code
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.