Reputation: 35
I have a form using jquery validation plugin. My submit button has an ajax handler, via which i want to call a binding method , when the button is clicked. I added some javascript to be run, before the ajax method is called. I want to call some method in the jquery validation plugin, which will return true or false, which will tell me if the form is valid or not, then i can continue my ajax call .
<h:commandButton id="altButton" tabindex="26" onclick="return processSubmit();" styleClass="input" value="I'm ready!">
<f:ajax> execute="@form" event="click" render="" listener="#{signup$MASSignupHandler.submitApplication}"/>
</h:commandButton>
function processSubmit(){
var temp = jQuery('#mainForm').submit();
alert ("done validation")
return true
}
the above method does do the validation, but this method still returns true and my ajax method gets called no matter if there's a validation error
Upvotes: 0
Views: 1131
Reputation: 100175
You could do:
$(document).ready(function() { $("#mainForm").submit() { //check if validations are fine if(validatedFine) { /your condition that checks if validation went fine return true; } else { return false; } }); });
Hope it helps
Upvotes: 1