Preventing a form submission

46 views
Skip to first unread message

Tony Nelson

unread,
Mar 26, 2015, 10:04:40 AM3/26/15
to tapestry...@googlegroups.com
Hi All,

Still using Tapestry 5.3.8 and tapestry-jquery 3.3.10, and I'm having a problem stopping form submission on a validation error. I'm listening for Tapestry.FORM_VALIDATE_EVENT, and that works fine.  I've tried setting event.result = false and just plain returning false, but nothing stops the form from submitting.

Here is what I have tried:

            $("#" + specs.form).on(Tapestry.FORM_VALIDATE_EVENT, function (event) {
                console.dir(event);
                event.result = false;
                return false;
            });

I even tried throwing an exception.  What is the proper way to register an error and stop form submission?

Thanks
Tony

Emmanuel DEMEY

unread,
Mar 27, 2015, 9:29:47 AM3/27/15
to tapestry...@googlegroups.com

Hi

Maybe event.stopPropagation() or event.preventDefault()

Manu

--
You received this message because you are subscribed to the Google Groups "tapestry5-jquery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tapestry5-jque...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tony Nelson

unread,
Mar 27, 2015, 1:47:11 PM3/27/15
to tapestry...@googlegroups.com
That will definitely stop it, but there is other code that needs to be executed, I presume to display error messages.  Looking at the source for tapestry-jquery.js, https://github.com/got5/tapestry5-jquery/blob/maint-3.3.x/src/main/resources/org/got5/tapestry5/jquery/tapestry-jquery.js , the event is triggered on line 594.  I need to figure out how I'm supposed to set thatOpt.validationError, that is checked on line 596.

This is the standard/correct way to do cross field validation, or is there a better way?

Thanks
Tony
Reply all
Reply to author
Forward
0 new messages