You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by NP-KARRYS MIKE <NP...@subcontractor.PRC.com> on 2002/09/05 17:05:17 UTC

Validation Javascript

Could somebody please explain the following. I'm probably missing something
simple but I just don't understand how the validate code is accessed and
called from the validation.xml and validation-rules.xml files.

When I pull up the struts-example application and look at the login page or
registration page from the source view on the browser, IE 6.0, there is
javascript at the bottom of the page.

The javascript cut from the logon form at the bottom of the file is.

<script language="JavaScript" type="text/javascript">
  <!--
 if (document.forms["logonForm"].elements["username"].type != "hidden") 
    document.forms["logonForm"].elements["username"].focus()
  // -->
</script>


<SCRIPT LANGUAGE="Javascript1.1"> 
<!-- Begin 

     var bCancel = false; 

    function validateLogonForm(form) {

        if (bCancel) 
      return true; 
        else 
       return validateMaxLength(form) && validateMinLength(form); 
   } 

    function maxlength () { 
     this.aa = new Array("username", "Username cannot be greater than null
characters.", new Function ("varName", "this.maxlength='16';
this.minlength='3';  return this[varName];"));
     this.ab = new Array("password", "Password cannot be greater than null
characters.", new Function ("varName", "this.maxlength='16';
this.minlength='3';  return this[varName];"));
    } 

    function minlength () { 
     this.aa = new Array("username", "Username cannot be less than 3
characters.", new Function ("varName", "this.maxlength='16';
this.minlength='3';  return this[varName];"));
     this.ab = new Array("password", "Password cannot be less than 3
characters.", new Function ("varName", "this.maxlength='16';
this.minlength='3';  return this[varName];"));
    } 


//  End -->
</SCRIPT>


<script language="Javascript1.1" src="staticJavascript.jsp"></script>

I can see how the validateLogonForm is called but not how the other code is
called.
How does the validateMaxLength and validateMinLength calls get executed when
they are not included, as far as I can see in the page source window, in the
downloaded page?

Mike Karrys


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