You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Steele <br...@paintedword.com> on 2002/07/26 18:02:12 UTC

struts unwillingly submitting form when using javascript to validate

Hi all,

Thanks in advance for any help.

Has anyone encountered an instance in which struts 1.0.2 submits a form without a submit button or a javascript call to submit()?

I'm using javascript to validate my form.  This is an extensive library of validation functions i've built up over many years and is fully tested, reliable, etc.  In short, i recurse through the javascript DOM to find any fields that require validation.  If the required fields pass the validation, I call "document.forms[ xx].submit()" otherwise an error message is displayed via an alert popup and no call to submit is made.

Somehow Struts is submitting the form anyway, even when I have no submit button or js call to submit ANYWHERE on the page.  The server logs show that struts starts processing the post after the javascript finishes (and no submit is called).

I'm running this on JRun 3.1

Here's the relevant code:

<html:form action="updateEmployee">
...
...
...
<html:image src="images/send.gif" alt="Send" onclick="javascript:validateForm( '3' );" /> **** 3 is the dom order of the form (4th form on page)****

</html:form>

---struts log ----- (reverse chronological)

07/26 11:13:59 info (JRun) payroll: Looking for Action instance for class com.xxx.payroll.action.UpdateEmployeePlanAction 
  [1176]   07/26 11:13:59 info (JRun) payroll: No errors detected, accepting input 
  [1175]   07/26 11:13:59 info (JRun) payroll: Validating input form properties 
  [1174]   07/26 11:13:59 info (JRun) payroll: Populating bean properties from this request 
  [1173]   07/26 11:13:59 info (JRun) payroll: Storing instance under attribute 'employeePlanForm' in scope 'request' 
  [1172]   07/26 11:13:59 info (JRun) payroll: Creating new ActionForm instance of class 'com.xxx.payroll.form.EmployeePlanForm' 
  [1171]   07/26 11:13:59 info (JRun) payroll: Looking for ActionForm bean under attribute 'employeePlanForm' 
  [1170]   07/26 11:13:59 info (JRun) payroll: Processing a POST for /updateEmployee

-Brian
   

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>