[html-formfu] Can I skip validation if they hit cancel?

Carl Franks fireartist at gmail.com
Fri Aug 31 09:33:36 GMT 2007


On 31/08/2007, Barry Hoggard <bhoggard at gmail.com> wrote:
> I would like to skip validation if a user hits cancel after making
> some changes.  Is that possible?

I've searched the XHTML 1 and HTML 4.01 specs, and there's no
reference to Cancel buttons at all.

Are you just using a 2nd Submit button, but changing the value to "Cancel"?

If so, the you need to set $form->indicator("submit"), where "submit"
is the name given to your Submit button.
This makes $form->submitted() true only if the Submit button's
name/value is sent.

Also make sure the Submit button is before the Cancel button in the
source, so if someone hits the 'enter' key somewhere else in the form,
the Submit's name/value is submitted, not the Cancel's.

You might also want to read Jakob Nielsen's "Cancel Button Considered
Harmful" [1], and forget Cancel buttons and the extra complexity they
bring - long live the Back button!

[1] http://www.useit.com/alertbox/20000416.html

Cheers,
Carl



More information about the HTML-FormFu mailing list