File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Data in form disappear after validating? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Data in form disappear after validating? " Watch "Data in form disappear after validating? " New topic
Author

Data in form disappear after validating?

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Hi,

Before I post a form I want to validate some fields in the form. If the fields isn�t valid, I will display a message. After clicking ok, all data in the form disappear... How can I avoid that?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60992
    
  65

Is this function your onsubmit hander? If so, you're not doing anything to stop the submission on error, and, since you are submitting the form from the fnction, you are risking double submits.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Originally posted by Bear Bibeault:
Is this function your onsubmit hander?


Yes I use that function to submit my form?:



Originally posted by Bear Bibeault:
If so, you're not doing anything to stop the submission on error, and, since you are submitting the form from the function, you are risking double submits.


Please tell me what I can do to stop the submission on error (and what kind of error?) and why do I risk to submit the form twice?
[ November 11, 2006: Message edited by: Jeppe Fjord ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60992
    
  65

Ummm, the problem is not what I thought it was...

Why on earth are you using a RESET button to submit the form? Of course it's going to reset all the values!
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
I see, the type (reset) of the button is the problem. I used the reset type, because I wanted to avoid i.e. to post the data twice.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
With validation you need to return true or false from the function to cancel the action and add return to where you call it.

"return functionName();"

You should not rely on a button for double posting, that is what the serverside code should do.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data in form disappear after validating?