I can submit my JSF generated form with this code :
<h:commandButton id="btnValidate" type="submit" value="#{rb.REGISTER}" action="#{login.registerAccount}" />
but I want to process JS code before submitting my form so I added onClick="test();"
with commandButton
type to button
:
<h:commandButton id="btnValidate" type="button" value="#{rb.REGISTER}" action="#{login.registerAccount}" onClick="test();" />
My test
function :
function test(){
$('#j_idt14\\:register_form').submit();
}
With this code, my form is submitted but my login.registerAccount
function is no longer called.
How to submit a form with JS and call server side function (attribute action
) ?