[Javascript] Regarding Password Validation

David Lovering dlovering at gazos.com
Mon Mar 1 10:59:30 CST 2004


On the regular expression you suggested, each part (numbers,
meta-characters) are in fact represented, but the way I'd interpret this is
2 or more digits followed by 1 or more meta-characters -- and nothing else.
Any additional characters, or when the numbers and meta characters do not
appear consecutively in this fashion would cause the expression to evaluate
"false".

Trying to write "OR'd" terms into a regex covering every possible
permutation would take too much brain power (and I have little enough to
spare at present).  It would also make the expression rather lengthy, and
hard to manage.  The method I suggested is certainly less elegent, but (a)
much faster, and (b) easier to make sense of.

-- Dave Lovering

----- Original Message ----- 
From: "Ramachandran" <ramachandran at summitworks.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Monday, March 01, 2004 8:45 AM
Subject: RE: [Javascript] Regarding Password Validation


> Hi Hakan,
>
> Yes i really need the Regular Expression for these conditions. If u find
> time...please write and send it to me...
>
>
>
> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu]On Behalf Of Hakan Magnusson
> Sent: Monday, March 01, 2004 9:06 PM
> To: [JavaScript List]
> Subject: Re: [Javascript] Regarding Password Validation
>
>
> Ramachandran,
> This could be accomplished with only one regexp, of course.
>
> My regexp skills are not quite up to date, but something that vaugely
> resembles this line should probably work:
>
> /[0-9]{2,}[^a-zA-Z0-9]{1,}/
>
> You can then test your password field value against the regexp, and it
> will return true if the password has at least two numbers and one
> special character.
>
> Again, my regexp skills are not very hot. Someone who do know the ins
> and outs of regexps can build this for you in the blink of an eye, this
> regexp is NOT complicated. If you really need me to, I can build it for
> you when I have the time.
>
> Dave,
> I don't know about 'missing 80% of the power of JavaScript', regexps
> have nothing to do with JavaScript. Saying that someone who doesn't know
> regexps are missing 80% of the power of string manipulation/testing
> sounds more accurate to me. ;)
>
> H
>
>
> David Lovering wrote:
>
> > The easiest way I can think of is to use two regular expression filters
to
> > strip (respectively) everything out EXCEPT numbers, and everything out
> > EXCEPT special characters.  The output of these two filters are put into
> two
> > strings, such as
> >
> > var digitString;
> > var specialString;
> >
> > ... and then simply check the length of the two strings to make sure
that
> > they are greater than or equal to 2 and 1, again respectively.
> >
> > If you're not up on regular expression filters, you're missing about 80%
> of
> > the power of JavaScript (at least IMO).
> >
> > Try
> >
> >   var re0 = /[^0-9]/g;
> >   var re1 = /[a-zA-Z0-9]/g;
> >
> >   var digitString = myString.replace(re0, "");
> >   var specialString = myString.replace(re1, "");
> >
> >   alert("number of digits: " + digitString.length);
> >   alert("number of special characters: " + specialString.length);
> >
> > Or some variation thereof.  Incidently, I'd also check myString (the
> target
> > string coming in) for total length as well, as short strings are easy to
> > crack.
> >
> > -- Dave Lovering
> > ----- Original Message -----
> > From: "Ramachandran" <ramachandran at summitworks.com>
> > To: "[JavaScript List]" <javascript at LaTech.edu>
> > Sent: Monday, March 01, 2004 6:42 AM
> > Subject: [Javascript] Regarding Password Validation
> >
> >
> >
> >>Hi all,
> >>
> >>I want to perform a validation in password field. The validation
includes
> >>the following conditions.
> >>
> >>1. It should contain atleast two no.s and once special characters.
> >>
> >>How can i do this one..
> >>
> >>Regards,
> >>Ram
> >>
> >>_______________________________________________
> >>Javascript mailing list
> >>Javascript at LaTech.edu
> >>https://lists.LaTech.edu/mailman/listinfo/javascript
> >>
> >>
> >
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> >
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>





More information about the Javascript mailing list