This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I have designed a login form for processing user login details name and password,but i am facing three problems.
1.even after providing a password in the field "Login Name" a alert window is opening--"please enter the Login Name".
2.even after entering the correct login details a alert box is opening--"please "please enter the Login Name" but alert box--"please enter the password" is never opening even after leaving the password field blank.
3.control is automatically transfered to "loginfailed.html" even after leaving either of fields blank.
code of login.jsp is given below-
Do you really not indent your code? Why make it difficult for people to read?
Just look at what you're doing: you return a value regardless of the results of the "name" validation. Pretend you're the computer--if you can't trace through the execution of a simple "if" statement you've got a long road ahead of you.
Joined: Oct 17, 2009
what does that mean
you return a value regardless of the results of the "name" validation.
please explain me clearly should i return "name" and "password"?
*Please* indent your code: do you see how you're making it unnecessarily difficult to see the intent of your code? Compare it with this:Also, please see ItDoesntWorkIsUseless. I see at least one trivial error; can you see it? Refactoring would make the error both (a) easier to spot, and (b) easier to fix, and have the side benefit of giving you something you could use throughout your application. As I refactored it I also found the actual error: simply displaying (via alert or logging) would make this very easy to fix.
That aside: what doesn't work?
Joined: Oct 17, 2009
thanks a lot.sir.but where the error is?help me in locating it?
- Are you validating the form values you think you are? How could you find out?
- If validation fails, are you focusing on the correct form element? Does it look like you are, when you examine the code lines that focus?
You need to slow down and think about what you're doing--I'm *not* going to just tell you what's wrong. The hints above should be enough to help you track down the problem: by answering the questions I've asked you'll find the problems.