You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Ayad <ma...@javamark.com> on 2002/11/13 00:49:40 UTC

ClientSide Validation Javascript Password field

I've noticed that the alertbox for clientside validation of a simple usename / password **never** shows alers for the password field.

Is this a known issue, or expected behaviour ?

Mark

Re: ClientSide Validation Javascript Password field

Posted by Mark Ayad <ma...@javamark.com>.
Solved by adding two lines to the

validator-rules.xml () from the struts-20021112 nightly build.

Added the following line to function validateMinLength

form[oMinLength[x][0]].type == 'password' ||

and also

Added the following line to function validateMaxLength

form[oMaxLength[x][0]].type == 'password' ||

<validator name="minlength"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateMinLength"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.minlength">

         <javascript><![CDATA[
            function validateMinLength(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oMinLength = new minlength();
                for (x in oMinLength) {
                    if (form[oMinLength[x][0]].type == 'text' ||
                      form[oMinLength[x][0]].type == 'password' ||
                        form[oMinLength[x][0]].type == 'textarea') {
                        var iMin = parseInt(oMinLength[x][2]("minlength"));
                        if (!(form[oMinLength[x][0]].value.length >= iMin))
{
                            if (i == 0) {
                                focusField = form[oMinLength[x][0]];
                            }
                            fields[i++] = oMinLength[x][1];
                            bValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            }]]>
         </javascript>

      </validator>


      <validator name="maxlength"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateMaxLength"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.maxlength">

         <javascript><![CDATA[
            function validateMaxLength(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oMaxLength = new maxlength();
                for (x in oMaxLength) {
                    if (form[oMaxLength[x][0]].type == 'text' ||
                      form[oMaxLength[x][0]].type == 'password' ||
                        form[oMaxLength[x][0]].type == 'textarea') {
                        var iMax = parseInt(oMaxLength[x][2]("maxlength"));
                        if (!(form[oMaxLength[x][0]].value.length <= iMax))
{
                            if (i == 0) {
                                focusField = form[oMaxLength[x][0]];
                            }
                            fields[i++] = oMaxLength[x][1];
                            bValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            }]]>
         </javascript>

      </validator>


----- Original Message -----
From: "Mark Ayad" <ma...@javamark.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 1:07 AM
Subject: Re: ClientSide Validation Javascript Password field


> If you turn:
>
> <html:password property="password" size="16"
maxlength="18"/>&nbsp;password
>
> into a normal text field then you get a clientside Javascript Alert,
> otherwise for the password type no alert is shown.
>
> <html:text property="password" size="16" maxlength="18"/>&nbsp;password
>
> Ideas ?
>
> ----- Original Message -----
> From: "Mark Ayad" <ma...@javamark.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, November 13, 2002 12:49 AM
> Subject: ClientSide Validation Javascript Password field
>
>
> I've noticed that the alertbox for clientside validation of a simple
usename
> / password **never** shows alers for the password field.
>
> Is this a known issue, or expected behaviour ?
>
> Mark
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>

Re: ClientSide Validation Javascript Password field

Posted by Mark Ayad <ma...@javamark.com>.
If you turn:

<html:password property="password" size="16" maxlength="18"/>&nbsp;password

into a normal text field then you get a clientside Javascript Alert,
otherwise for the password type no alert is shown.

<html:text property="password" size="16" maxlength="18"/>&nbsp;password

Ideas ?

----- Original Message -----
From: "Mark Ayad" <ma...@javamark.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 12:49 AM
Subject: ClientSide Validation Javascript Password field


I've noticed that the alertbox for clientside validation of a simple usename
/ password **never** shows alers for the password field.

Is this a known issue, or expected behaviour ?

Mark



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


Re: ClientSide Validation Javascript Password field

Posted by Mark Ayad <ma...@javamark.com>.
Martin

That being said then the serverside validation shows you what the clientside
doesn't

But now there is a problem, if you're not validate on min / max length for a
password field at all how are we going to enforce strong passwords ?

Surely you have to define the keyspace somehow to enforce it ?

Mark



----- Original Message -----
From: "Martin Cooper" <ma...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 1:34 AM
Subject: Re: ClientSide Validation Javascript Password field


>
>
> On Wed, 13 Nov 2002, Mark Ayad wrote:
>
> > Well is that expected behaviour is logical ??
>
> Yes. Did you read the explanation in the bug report I referenced?
>
> --
> Martin Cooper
>
>
> >
> > Enforcing length of a password field ?
> >
> > Or is it that this is best left to be serverside validation ?
> >
> > Mark
> >
> > ----- Original Message -----
> > From: "Martin Cooper" <ma...@apache.org>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Wednesday, November 13, 2002 1:25 AM
> > Subject: Re: ClientSide Validation Javascript Password field
> >
> >
> > >
> > >
> > > On Wed, 13 Nov 2002, Mark Ayad wrote:
> > >
> > > > I've noticed that the alertbox for clientside validation of a simple
> > usename / password **never** shows alers for the password field.
> > > >
> > > > Is this a known issue, or expected behaviour ?
> > >
> > > It's expected behaviour. See:
> > >
> > > http://issues.apache.org/bugzilla/show_bug.cgi?id=12473
> > >
> > > --
> > > Martin Cooper
> > >
> > >
> > > >
> > > > Mark
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


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


Re: ClientSide Validation Javascript Password field

Posted by Mark Ayad <ma...@javamark.com>.
Oh I didn't see that far down - Yep I see the reason for this. Crystal
Clear.

It's 1:45 am in Paris.

Thanks Martin

I'll un-patch my file now. Still at least I could follow the logic of the
javascript.

----- Original Message -----
From: "Martin Cooper" <ma...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 1:34 AM
Subject: Re: ClientSide Validation Javascript Password field


>
>
> On Wed, 13 Nov 2002, Mark Ayad wrote:
>
> > Well is that expected behaviour is logical ??
>
> Yes. Did you read the explanation in the bug report I referenced?
>
> --
> Martin Cooper
>
>
> >
> > Enforcing length of a password field ?
> >
> > Or is it that this is best left to be serverside validation ?
> >
> > Mark
> >
> > ----- Original Message -----
> > From: "Martin Cooper" <ma...@apache.org>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Wednesday, November 13, 2002 1:25 AM
> > Subject: Re: ClientSide Validation Javascript Password field
> >
> >
> > >
> > >
> > > On Wed, 13 Nov 2002, Mark Ayad wrote:
> > >
> > > > I've noticed that the alertbox for clientside validation of a simple
> > usename / password **never** shows alers for the password field.
> > > >
> > > > Is this a known issue, or expected behaviour ?
> > >
> > > It's expected behaviour. See:
> > >
> > > http://issues.apache.org/bugzilla/show_bug.cgi?id=12473
> > >
> > > --
> > > Martin Cooper
> > >
> > >
> > > >
> > > > Mark
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


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


Re: ClientSide Validation Javascript Password field

Posted by Martin Cooper <ma...@apache.org>.

On Wed, 13 Nov 2002, Mark Ayad wrote:

> Well is that expected behaviour is logical ??

Yes. Did you read the explanation in the bug report I referenced?

--
Martin Cooper


>
> Enforcing length of a password field ?
>
> Or is it that this is best left to be serverside validation ?
>
> Mark
>
> ----- Original Message -----
> From: "Martin Cooper" <ma...@apache.org>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, November 13, 2002 1:25 AM
> Subject: Re: ClientSide Validation Javascript Password field
>
>
> >
> >
> > On Wed, 13 Nov 2002, Mark Ayad wrote:
> >
> > > I've noticed that the alertbox for clientside validation of a simple
> usename / password **never** shows alers for the password field.
> > >
> > > Is this a known issue, or expected behaviour ?
> >
> > It's expected behaviour. See:
> >
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=12473
> >
> > --
> > Martin Cooper
> >
> >
> > >
> > > Mark
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


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


Re: ClientSide Validation Javascript Password field

Posted by Mark Ayad <ma...@javamark.com>.
Well is that expected behaviour is logical ??

Enforcing length of a password field ?

Or is it that this is best left to be serverside validation ?

Mark

----- Original Message -----
From: "Martin Cooper" <ma...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 1:25 AM
Subject: Re: ClientSide Validation Javascript Password field


>
>
> On Wed, 13 Nov 2002, Mark Ayad wrote:
>
> > I've noticed that the alertbox for clientside validation of a simple
usename / password **never** shows alers for the password field.
> >
> > Is this a known issue, or expected behaviour ?
>
> It's expected behaviour. See:
>
> http://issues.apache.org/bugzilla/show_bug.cgi?id=12473
>
> --
> Martin Cooper
>
>
> >
> > Mark
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


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


Re: ClientSide Validation Javascript Password field

Posted by Martin Cooper <ma...@apache.org>.

On Wed, 13 Nov 2002, Mark Ayad wrote:

> I've noticed that the alertbox for clientside validation of a simple usename / password **never** shows alers for the password field.
>
> Is this a known issue, or expected behaviour ?

It's expected behaviour. See:

http://issues.apache.org/bugzilla/show_bug.cgi?id=12473

--
Martin Cooper


>
> Mark
>


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