You do not need to submit the form if you are using an input type="image". That's what it does if it is pressed (unless the image is outside of the <form>...</form> tags. Make sure your html:form has the proper onsubmit="return validateXYZForm()" (notice that 'return' will stop the page from submitting if validation fails), just calling validateXYZForm() will still allow the request to continue in most browsers.
(this will look a little different depending on which incarnation you are using ValidatorForm/ValidatorActionForm (with or without Dyna) ) <form action="/myAction" onsubmit="return validateXYZForm()"> ... ... <html:image onclick="document.forms[0].Dispatch.value='Save';" page="/images/btn_primary_action_save.gif" align="right" onmouseover="src='/images/btn_primary_action_save_roll.gif'" onmouseout="src='/images/btn_primary_action_save.gif'"/> <html:javascript dynamicJavascript="true" staticJavascript="false" formName="/myAction" method="validateXYZForm"/> </form> -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, September 20, 2004 5:42 PM Subject: Re: Validation problem - form still submits after client-side validat ion fails. > > > > > If I'm understanding your scenario correctly your onclick needs to call a > function that will call the submit() on the form only if the validation > passes. > > > "Barnett, Brian W." <[EMAIL PROTECTED]> wrote on 09/20/2004 04:51:55 > PM: > > > Both the client-side and the server-side validation are executing instead > of > > just the client-side. I know it has something to do with the way I've > coded > > the save button. The underlying problem is that I want to use images and > > roll-over images for the save button but I also want the "enter" key to > > submit the form. > > > > > > > > Here is the save button code in the jsp: > > > > > > > > <input type="image" > > > onclick="document.forms[0].Dispatch.value='Save';document.forms[0].submit(); > > > " src="/images/btn_primary_action_save.gif" align="right" > > onmouseover="src='/images/btn_primary_action_save_roll.gif'" > > onmouseout="src='/images/btn_primary_action_save.gif'"/> > > > > > > > > The roll-over images works, and the "enter" key works but it looks like > the > > form still gets submitted after client-side validation fails. Does anyone > > know how to prevent that and still maintain images and "enter" key > > functionality? > > > > > > > > Thanks, > > > > Brian Barnett > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]