• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data in form disappear after validating?

 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic