Anirudh Zala wrote:
On Wednesday 03 Oct 2007 06:30:04 Urb LeJeune wrote:
Had a client who twice lost existing content while making a change
using a CMS. Turns out the problem was they he was using a DSL line
and he made a change and hit the "Submit Changes" button before the
page had fully downloaded. Needless to say the undownloaded textarea
fields were empty and were written to the DB.
Is there a way to disallow a form submit before the entire form
has downloaded?
Simplest solution is to keep submit button disabled by default, and then
enabling it by javascript when page is loaded.
Technically it can be done like this.
# While writing submit tag, keep it disabled by default.
# In the form where this button exists, put javascript code at the end of page
to make it enabled.
By this way until page will get reloaded, Submit button would not be available
in press/click mode.
Thanks
Anirudh Zala
Agreed. Also, in case the user hits enter to submit, you should force
the form's onsubmit to do nothing while form is loading.
You can also check that the form was fully loaded on the server side (in
case javascript was off or otherwise futzed with), by checking for the
existence of the last field in the form. As long as it's not a checkbox
/ radio button, even if it's blank it'll still send the data.
if (array_key_exists('last_field', $_POST) === false) {
// show form with warning or change sql to exclude field
}
Mark Armendariz
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php