[Javascript] Regarding Password Validation

Ramachandran ramachandran at summitworks.com
Mon Mar 1 09:45:37 CST 2004


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




More information about the Javascript mailing list