0

I'm facing a problem within JSF ajax request and jQuery Event.

I'm using jQuery event to validate a form part like this :

    jQuery(".btnNextStep").live("click", function(e) {
    var error = !validate(id);
            ...
    return error;

and under the same button, I have an Ajax event :

<h:commandButton type="button" value="Etape suivante" class="btn btn-large btn-primary btnNextStep" id="btnFormIdentite">
<f:ajax execute="identite" render="@none" />
</h:commandButton>

The problem is that the ajax request is submited even if jQuery event return false !

how can I do so that the request is sent after the jquery validation function ?

I have tried the onEvent on f:ajax but it seem that it's not possible to call a function inside of the jQuery namespace:

 (jQuery(document).ready( function() {...)

I hope you understand my problem. Thanks.

4b0
  • 21,981
  • 30
  • 95
  • 142

1 Answers1

0

Try define your validate function like this :

function vlidateNextStep() {
    var error = false;
    error = !validate(id);
            ...
    return error;
}

And use on click:

<h:commandButton type="button" value="Etape suivante" class="btn btn-large btn-primary btnNextStep" id="btnFormIdentite" onClick="return vlidateNextStep();">
    <f:ajax execute="identite" render="@none" />
</h:commandButton>
Mohamed AbdElRazek
  • 1,654
  • 14
  • 17