title: Avoid AJAX onsuccess call, when field validation fails
body: <p>I'm tying to build a wizard on my website. Like every wizard, it has steps. For every step you can go either forward or backwards to previous step. I'm handling this navigation among steps with ajax. Every step is defined on a div. Each step has the same class, and a unique id which indicates the step. So, for navigating I defined the following js function, On which the parameter is the id of the step to show.</p>
  
  <pre><code>function navigateStepWizard(id) {
          //hide all steps
          $('.wizard-step').hide();
          //show proper step
          $(id).fadeIn("fast");
          return false;
  }
  </code></pre>
  
  <p>Now, the problem I'm facing is that on one of this steps I have several fields that must be validated before going to next step. I've defined validators (Faces Validator Clases) for each field on a form which are being executed when trying to go to next step, returning appropriate Ok/Error messages. My problem is that when this fields are not correct, the button does go to next step. First I've tried to use <code>oncomplete</code> which always executed the js function, so I've changes to <code>onsuccess</code> thinking that when a validation is not ok, the ajax callback wont execute the <code>onsuccess</code> js function, but it does... here's my button code</p>
  
  <pre><code>&lt;p:commandLink id="go-to-step-X" 
                 actionListener="#{myBean.submitWizardInfo}" 
                 onsuccess="navigateStepWizard('#wizard-step-X');" 
                 process="@form, @([id$=wizzard])" 
                 update="@form, @([id$=wizzard])"&gt;
      Go to next step...                                    
  &lt;/p:commandLink&gt;
  </code></pre>
  
  <p>Is there a way to do this avoiding the <code>onsuccess</code> AJAX call when a field is not ok? Thanks for your time!</p>
  
  <p>P.D: I'm using JSF 2.0 &amp; PrimeFaces 5.0. </p>