title: jQuery function is not calling from JSF on button click
body: <p>I have a jQuery file with function in it. When my page loads then my script runs. Means it's invoke. Here is my jQuery file.</p>
  
  <pre><code>(function($){
  
      var $firstPara = $('p').eq(1);
      $firstPara.hide();
  
      function checkValidation() {
  
          var labelElementArray = $("label.mandotary");
          var inputElementArray = $("input.mandotary");
          var selectElementArray = $("select.mandotary");
  
          $.each(inputElementArray, function(index, element){
  
              var text = $(element).text();
  
  
          }); //end of $.each(inputElementArray, fn)
  
          $.each(selectElementArray, function(index, element) {
  
              ////nothing
  
          }); //end of  $.each(selectElementArray, fn)
  
      } //end of function checkValidation()
  
  })(jQuery); //end of (function($){}
  </code></pre>
  
  <p>I have JSF form with button in it. </p>
  
  <pre><code>&lt;h:head&gt;
      &lt;title&gt;Facelet Title&lt;/title&gt;
      &lt;h:outputScript library="javascripts" name="jquery.js"  target="body"/&gt;
      &lt;h:outputScript library="javascripts" name="validation.js" target="body"/&gt;
  
  &lt;/h:head&gt;
  
  &lt;h:body&gt;
  
      &lt;h:form id="validationFrom" &gt;
  
          &lt;h:commandButton id="saveButton"
                           value="Save"
                           onclick="checkValidation()"/&gt;
  
  
          &lt;h:commandButton id="cancelButton"
                           value="Cancel" /&gt;
  
      &lt;/h:form &gt;
  
  &lt;/h:body&gt;
  </code></pre>
  
  <p>Now when i click on save button, it says that checkValidation() function is undefined. Why?
  What i am doing wrong here?</p>
  
  <p>Thanks</p>