| Author |
h:commandLink and onsubmit
|
Arine Vasan
Greenhorn
Joined: Feb 21, 2004
Posts: 8
|
|
Hi, I have a javascript validation onsubmit of my form. When I click the commandLink the js gets called and throws the alert for validation failure. But the form submits even when the validation fails. Could you please let me know if I am not using this correctly. SCRIPT: function validate(){ if (..){ }else{ alert('Validation Error'); return false; } return true; } FORM: <h:form id="frmSave" onsubmit="return validate();"> .... <h:commandLink action="#{mBean.save}"> <h utputText value="Save" styleClass="button-text"/> </h:commandLink> </h:form> Thanks, Aruna
|
SCJP, SCWCD, SCMAD, SCEA-1
|
 |
Paul Michael
Ranch Hand
Joined: Jul 02, 2001
Posts: 697
|
|
I also had this problem with commandLink's onclick method before. I needed to perform some JS validations on the onlick method and should continue/stop submission depending on the result. I found out that it didn't work with commandLink, I switched to commandButton and it worked fine.
|
SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
|
 |
 |
|
|
subject: h:commandLink and onsubmit
|
|
|