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.
(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($){}
I have JSF form with button in it.
<h:head>
<title>Facelet Title</title>
<h:outputScript library="javascripts" name="jquery.js" target="body"/>
<h:outputScript library="javascripts" name="validation.js" target="body"/>
</h:head>
<h:body>
<h:form id="validationFrom" >
<h:commandButton id="saveButton"
value="Save"
onclick="checkValidation()"/>
<h:commandButton id="cancelButton"
value="Cancel" />
</h:form >
</h:body>
Now when i click on save button, it says that checkValidation() function is undefined. Why? What i am doing wrong here?
Thanks