I'm on a JSF h:form submit via JavaScript.It's a simple function.I need a validation for inputs before submit while I want to use JavaScript instead of JSF Validator for some dynamic effect. but the submit method is a managed bean function called #{depositMB.deposit} Here's the code:
JS:
function checkAccount(form){
//some validations here
form.submit();
}
XHTML:
<h:form class="form-horizontal" onsubmit="#{depositMB.deposit()}">
<h:inputText id="account" value="#{depositMB.targetAccount.accountNumber}"/>
<h:inputText id="money" value="#{depositMB.moneyAmount}"/>
<h:commandButton value="Deposit" action="checkAccount(form)"/>
</h:form>
When I wrote it in the tag h:form as onSubmit:#{depositMB.deposit} it doesn't work. Then I put it in JS like this
function checkAccount(){
//some validations
#{depositMB.deposit()};
}
<h:form class="form-horizontal">
<h:inputText id="account" value="#{depositMB.targetAccount.accountNumber}"/>
<h:inputText id="money" value="#{depositMB.moneyAmount}"/>
<h:commandButton value="Deposit" action="checkAccount(form)"/>
</h:form>
It didn't work either...Who can help me with this... Thx a lot