You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gabriel Belingueres <be...@gmail.com> on 2007/10/23 20:59:22 UTC
[S2] Problem with simple theme javascript validation
Hi,
I'm trying to perform some basic javascript validation using a form
with the simple theme.
I just added the onsubmit parameter in the form tag:
<s:form .... onsubmit="return validate();">
but the form is ALWAYS posted, so there might be an error somewhere.
Looking at the html source code, the form.ftl template generates
<form ... on submit="return validate(); return true;">
so this is why it is always posting the form data.
I just changed the form.ftl template file from:
<#if (parameters.validate?default(false) == false)><#rt/>
<#if parameters.onsubmit?exists><#rt/>
${tag.addParameter('onsubmit', "${parameters.onsubmit}; return true;") }
<#else>
${tag.addParameter('onsubmit', "return true;") }
</#if>
</#if>
to:
<#if (parameters.validate?default(false) == false)><#rt/>
<#if parameters.onsubmit?exists><#rt/>
${tag.addParameter('onsubmit', "${parameters.onsubmit};") }
<#else>
${tag.addParameter('onsubmit', "return true;") }
</#if>
</#if>
My question is:
Am I using the either the simple template or the form tag incorrectly?
Or it is just a bug in the template?
BTW, isn't it this lines just doing nothing?:
<#else>
${tag.addParameter('onsubmit', "return true;") }
</#if>
Gabriel
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org