hi,
try to use onClick instead of onSubmit when you are using the javaScript
submit

Cheers,
Vishal



-----Original Message-----
From: Jim Reynolds [mailto:[EMAIL PROTECTED]
Sent: Friday, November 04, 2005 7:12 PM
To: user@struts.apache.org
Subject: Client Side Validator Fails When Submit from Javascript


I have been playing with the client-side validation, and ran into a
problem last night that I can docuemnt, but cannot figure out why it
fails.

The below file, shows a form and when you hit the submit, presents the
appropriate alert box with the proper message. All is good, and works
when the "submit" is pressed.

But if you try and use a javascript:document.form.submit(), the
document is submitted but the alert does NOT work. So basically the
validation fails.

I have tried multiple ideas, and all have not worked. But I really
need the ability to do submits from a javascript: Technically, I was
unare of any difference between a submit button, and a submit form
using the javascript:

Anyone?

Here 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Make your callers hear anything you like.Call 456 say DIALER TONES.

An idea can change your life. 

************** LEGAL DISCLAIMER ************
This E-Mail may contain Confidential and/or legally privileged Information and 
is meant for the intended recipient(s) only. If you have received this e-mail 
in error and are not the intended recipient/s, kindly notify us at [EMAIL 
PROTECTED] and then delete this e-mail immediately from your system. You are 
also hereby notified that any use, any form of reproduction, dissemination, 
copying, disclosure, modification, distribution and/or publication of this 
e-mail, its contents or its attachment/s other than by its intended recipient/s 
is strictly prohibited and may be unlawful.

Internet Communications cannot be guaranteed to be secure or error-free as 
information could be delayed, intercepted, corrupted, lost, or contain viruses. 
IDEA Cellular Limited does not accept any liability for any errors, omissions, 
viruses or computer problems experienced by any recipient as a result of this 
e-mail.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to