The only approach I see is to find all those inline event handlers and
replace them with something that goes through the jQuery event chain,
including validation.

Something like this:

$("a[onclick]").each(function() {
  this.onclick = function() {};
  $("#form").submit();
});

Jörn

On Mon, Mar 30, 2009 at 3:57 PM, Yeuker <yeu...@gmail.com> wrote:
>
> For those of you who frequent the jqueryhelp.com pages, forgive my
> question here as well.
>
> I am using the excellent jquery validation plugin found here:
>
> http://docs.jquery.com/Plugins/Validation
>
> It works incredibly well and am very happy with it (thanks).  My
> problem is that sometimes my forms are submitted via document.forms
> ['formid'].submit().  I have no control over this statement as it is
> generated for me by jsf when it is rendering the element, which in my
> case is an anchor.
>
> Because it is getting submitted via document.forms['formid'].submit(),
> the jquery validation plugin does not catch this submit, therefor does
> not validate, therefor submits the form when it shouldn't.  I've been
> stuck here for quite some time and could really use some help on how
> to get jquery to validate when a form is submitted this way.  Any help
> would be greatly, greatly appreciated.
>
> I have posted some code below that shows that the submit handler does
> not catch the javascript submit.
>
>
> <form name="aform" id="aform">
>   <input type="submit" /><br/>
>   <a href="#" onclick="$('#aform').submit();">submit with jquery</
> a><br/>
>   <a href="#" onclick="document.forms['aform'].submit();">submit with
> old js</a>
> </form>
>
> <script type="text/javascript">
>
>   $(document).ready(function(){
>      $("#aform").submit(
>         function(){ alert("Submitted"); });
>   });
> </script>
>
> Thanks so much,
>
> Yeuker
>
>

Reply via email to