Sandeep,

The validateEnterAppInfo1(form) method gets called with the submit button
hardcode w/i the <html:form>.  

If I remove the validateEnterAppInfo1(this) call, no javascript validation
will take place, while the server-side validation still works.

There is always going to be only one form per page, so using
document.forms[0].submit() should be ok.

When this form pass validation the data is submitted.


This is part of the generated javascripts:

<script type="text/javascript" language="Javascript1.1"> 

<!-- Begin 

     var bCancel = false; 

    function validateEnterAppInfo1(form) {

        if (bCancel) 
      return true; 
        else 
       return validateRequired(form); 
   } 

    function required () { 
     this.aa = new Array("primAddrState", "Please select your state of
residence to continue.", new Function ("varName", " return
this[varName];"));
    } 

    function validateRequired(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oRequired = new required();
                for (x in oRequired) {
                        var field = form[oRequired[x][0]];
                        
                    if (field.type == 'text' ||
                        field.type == 'textarea' ||
                        field.type == 'file' ||
                        field.type == 'select-one' ||
                        field.type == 'radio' ||
                        field.type == 'password') {
                        
                        var value = '';
                                                // get field's value
                                                if (field.type ==
"select-one") {
                                                        var si =
field.selectedIndex;
                                                        if (si >= 0) {
                                                                value =
field.options[si].value;
                                                        }
                                                } else {
                                                        value = field.value;
                                                }
                        
                        if (value == '') {
                        
                                if (i == 0) {
                                    focusField = field;
                                }
                                fields[i++] = oRequired[x][1];
                                isValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return isValid;
            }

    function required () { 
       this.aa = new Array("primAddrState", "Please select your state of
residence to continue.", new Function ("varName", " return
this[varName];"));
    } 

-----Original Message-----
From: Sandeep Takhar [mailto:[EMAIL PROTECTED]
Sent: Monday, July 07, 2003 11:29 AM
To: Struts Users Mailing List
Subject: RE: Validator using <A href> instead of <html:submit>


What is the javascript created by the custom tag when
looking at the source?

I think you shouldn't need to call:
validateEnterAppInfo1(this)

but what happens if you do?

maybe there is more than one form?  Is the form being
submitted and the data is in the form?

sorry I can't help any more than that.

sandeep


--- "Poon, Johnny" <[EMAIL PROTECTED]> wrote:
> Sandeep,
> 
> No, because I'm using the same bean across different
> screen, so
> ValidatorActionForm suits me better, as it validates
> based on the action
> instead of the form.
> 
> JP
> 
> -----Original Message-----
> From: Sandeep Takhar
> [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 07, 2003 10:48 AM
> To: Struts Users Mailing List
> Subject: Re: Validator using <A href> instead of
> <html:submit>
> 
> 
> should it be a validatorForm?
> 
> sandeep
> --- "Poon, Johnny" <[EMAIL PROTECTED]> wrote:
> > Hi,
> > 
> > I'm using trying to use ValidatorActionForm and
> > tile, but the submit button
> > is outside of the  form on a different JSP,
> > therefore, I need to submit my
> > form indirectly using a link and javascript (see
> > code below).  Neither the
> > client-side javascript nor the server-side
> > validation get called.  But if I
> > hardcode a submit button WITHIN the form, the
> > javascript will get called.
> > 
> > So, does this mean that validator will not work
> with
> > document.forms[0].submit(); ?  Is there a
> workaround
> > this?  I'm sure there
> > are someone out there doing similar thing.
> > 
> > Thanks!
> > 
> > JP
> > 
> > 
> > 
> > My action form:
> > 
> >      <html:form action="/enterAppInfo1"
> > onsubmit="validateEnterAppInfo1(this);">
> >           <html:errors />&nbsp;
> >           <html:select property="primAddrState"
> > onchange='runSelectOnChange();'>
> >              <html:optionsCollection label="label"
> > value="value" name="..."
> > property="..." />
> >           </html:select>
> >      </html:form>
> > 
> >      <html:javascript formName="enterAppInfo1" />
> > 
> > 
> >      <!-- Assuming one form per page, in the end
> of
> > doSomethingBeforeSubmit(...), I'm calling: -->
> >      <!-- document.forms[0].submit(); -->
> >      <A
> > href="javascript:doSomethingBeforeSubmit(...);"/>
> >           <IMG name="..." src="..."
> >           
> >
>
onmouseover="javascript:submitChoiceOnMouseOver(...);return
> > true;"
> >           
> >
>
onmouseout="javascript:submitChoiceOnMouseOut(...);return
> > true;"
> >            alt="....." border="0"></A>
> > 
> > My validation.xml:
> > 
> >     <formset>
> >             <form name="enterAppInfo1">
> >                     <field property="primAddrState"
> > depends="required">
> >                             <msg name="required"
> > key="errors.state.required" />
> >                     </field>
> >             </form>
> >     </formset>
> > 
> > 
> >
>
**********************************************************************
> > This email and any files transmitted with it are
> > confidential and
> > intended solely for the use of the individual or
> > entity to whom they
> > are addressed. If you have received this email in
> > error please notify
> > the system manager.
> >
>
**********************************************************************
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
>
**********************************************************************
> This email and any files transmitted with it are
> confidential and
> intended solely for the use of the individual or
> entity to whom they
> are addressed. If you have received this email in
> error please notify
> the system manager.
>
**********************************************************************
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


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

Reply via email to