Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data in form disappear after validating?

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic