Submit Struts Form with JavaScript
843838Jan 26 2006 — edited Dec 4 2006I have a JSP page with java script and form as shown below. When I click on the button, the javascript alerts the message "About to submit form" but the form is never submitted. Any ideas why?
Thanks.
<script type="text/javascript">
function validateTheForm ()
{
alert("About to submit form");
document.forms['addUserForm'].submit();
}
</script>
<html:form action="AddUser.do?do=addUser" enctype="multipart/form-data">
<table border=0>
<tr>
<td align=right><strong><font size="2" face="Verdana"><bean:message key="adduser.label.userId"/>:</font></strong></td>
<td align=left><html:text property="userId" maxlength="20"/></td>
<td><html:errors property="userId"/></td>
</tr>
</table>
<br><br>
<html:button property="submit" onclick="javascript:validateTheForm();">Submit</html:button>
</html:form>