User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 392,091 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,933 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 621 | Replies: 3 | Solved
Reply
Join Date: Jun 2007
Posts: 15
Reputation: saswati_mishra is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
saswati_mishra saswati_mishra is offline Offline
Newbie Poster

Help Entires become blank in jsp

  #1  
Aug 9th, 2007
Hi,

I have a jsp page where the user is asked to do certain entries. Now if the user leaves any one of the entires as blank or as a wrong entry and presses the submit button, he gets an alert message.

Now after the user presses okay,, the page entries becomes either blank or null and then the user has to enter everything again.

Can any one help me.


Thanks a ton in advance

Saswati
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,646
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 191
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Entires become blank in jsp

  #2  
Aug 9th, 2007
You obviously don't return the values to the page for display after you handle them.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,775
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 330
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Entires become blank in jsp

  #3  
Aug 10th, 2007
If you are by any chance attaching or calling the validation function to the 'onclick()' event of the 'submit' button, you need to return a value from the validation function to prevent the trip to the server and to make the data in the form fields persist.

<html>
<head>
    <script type="text/javascript">
    var SOS = {};
    
    SOS.validate = function(myForm)
    {
        var returnCode = true;
        if(myForm.elements['txt'].value.length == 0)
        {
            alert('YOu need to enter something');
            returnCode = false;
        }
        return(returnCode);        
    }
    
    </script>
</head>
<body>
    <form action="./Servlet?QueryString">
        <input type="text" id="txt" name="txt" />
        <br />
        <input type="submit" onclick="return SOS.validate(this.form);" />
    </form>
</body>
</html>

Of course I would like to point out here that client side validation sucks and are of no value whatsoever. Real validations are done at the server. The javascript executing on the client is entirely at the mercy of the person sitting in front of the computer on which it is executing, and so client-side code provides precisely zero security.
Last edited by ~s.o.s~ : Aug 10th, 2007 at 2:24 am.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Jun 2007
Posts: 15
Reputation: saswati_mishra is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
saswati_mishra saswati_mishra is offline Offline
Newbie Poster

Re: Entires become blank in jsp

  #4  
Aug 10th, 2007
Thank you jwenting. My Problem is solved now.


Saswati
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JSP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 12:37 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC