You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Reynolds <ji...@gmail.com> on 2005/11/07 20:48:55 UTC

Difference between and JS submit.

I posted this email a week ago, and received no response, so I am
going to try again and change my verbage.

Below is a JSP file which uses struts client-side validation. The
validtion works great when you use either the <html:submit> or a
normal<input type="submit">. This is all good.

Problem is, when you use legal javascript to submit the form, the
validation does NOT work. Myself and other co-workers cannot
understand why this is? Does anyone know why?

The JSP file is below, and can easily be run and played with. I really
was hoping someone had an idea why, because I would like to perform
the client-side and need to change actions, etc. with JS.

Thanks,


IHere is the jsp page, in case one sees something odd:

<%@ include file="/tags.jsp" %>

<html:html locale="true">
<head>
    <title>fyi</title>
<html:base/>
</head>
<body bgcolor="white">
<html:form action="/AddressJavascriptValidation" method="post"
onsubmit="return validateAddressForm(this);">

<td align="center" colspan="2">
<font size="4"><b>Please Enter the Following Details</b></font>
</tr>
<tr>
<td align="right">
<b>Name</b>
</td>
<td align="left">
<html:text property="name" size="30" maxlength="30"/>
</td>
</tr>
<tr>
<td align="right">
<b>Address</b>
</td>
<td align="left">
<html:text property="address" size="30" maxlength="30"/>
</td>
</tr>


// HERE IS A LINK USING SIMPLE JAVASCRIPT TO SUBMIT THAT
// FAILS.********************************************************************

<a href="javascript:document.AddressForm.submit()">doit</a>

<tr>
<td align="right">
<b>E-mail address</b>
</td>
<td align="left">
<html:text property="emailAddress" size="30" maxlength="30"/>
</td>
</tr>

<tr>
<td align="right">
<html:submit>Save</html:submit>
</td>
<td align="left">
<html:cancel>Cancel</html:cancel>
</td>
</tr>
</table>
</div>

<!-- Begin Validator Javascript Function-->
<html:javascript formName="AddressForm"/>
<!-- End of Validator Javascript Function-->

</html:form>
</body>
</html:html>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org