Hi all,
I am working with jQuery and after looking over other questions, I cannot seem to find an answer to the problem I have. I am trying to validate a form and submit it in one action. It work's fine it I use a submit button, but it I try and call the trigger from another function it fails.
jQuery code:
$(document).ready(function(){
$('#cmdSave').click(function (){
if ($('#age').val() != $('#agechk').val()) {
//Do something
}
else {
//Set form varaible
$('#frmactn').val('Save');
//Call form submit
$('#frmPrflDtls').submit();
}
});
$('#frmPrflDtls').submit(function() {
return vrfyDetails();
});
});
html:
<form name="frmPrflDtls" id="frmPrflDtls" method="get" action="details.php">
<input name="frmactn" id="frmactn" type="hidden" />
<input name="agechk" id="agechk" type="hidden" value="Senior" />
<input type="text" name="age" id="age" value="Senior" />
<input type="button" id="cmdSave" value="Save" />
</form>
So if I comment out the #cmdSave function and change the button type to submit all is well, but as it is, it will only validate false, or do nothing, but it never submits.
Thanks for any help.