You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Aruna Kumaraswamy <ar...@yahoo.com> on 2005/07/04 18:03:13 UTC
h:commandLink and onsubmit
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:outputText value="Save" styleClass="button-text"/>
</h:commandLink>
</h:form>
Thanks,
Aruna
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: h:commandLink and onsubmit
Posted by Slawek <ss...@o2.pl>.
i dont know why your form is submited and if it should be or not, but try
do it another way
<h:commandLink action="#{mBean.save}" onclick="return validate()">
return is very importand!
Slawek
> 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:outputText value="Save" styleClass="button-text"/>
> </h:commandLink>
> </h:form>
>
> Thanks,
> Aruna
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Re: h:commandLink and onsubmit
Posted by Zarar Siddiqi <za...@utoronto.ca>.
Post the generated <form> code.
----- Original Message -----
From: Aruna Kumaraswamy
To: users@myfaces.apache.org
Sent: Monday, July 04, 2005 12:03 PM
Subject: h:commandLink and onsubmit
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:outputText value="Save" styleClass="button-text"/>
</h:commandLink>
</h:form>
Thanks,
Aruna
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com