...

View Full Version : Validation



owen_yuen
10-13-2003, 06:05 PM
I am used to use vbscript doing form validation. How I can
validate user's inital their new password as following rule in JS.


1) At Least one embedded numeric

2) Charactor can't repeat more than twice.

3) Length can not more than 10 charactors. (I am Okay for this rule)

Any help

lavalamp
10-13-2003, 11:48 PM
Is this any good:

owen_yuen
10-15-2003, 06:59 PM
Thanks!

It works Great! It help me LOT since it works lot of diff from VBScript. Thanks for your share the coding!!!

One more question if you don't mind.

If I don't allow charactors repeat more than twice the way as below example. Does it a major change for the coding?

Valid password: awnnq86pzn

Invalid password: awnnnq86pz


Thanks
Owen

owen_yuen
10-15-2003, 07:07 PM
Valid password: awnnq86pzn
Invalid password: awnnnq86pz

Valid password: awnn66qpzn
Invalid password: awnnq666Z


Thanks
Owen

lavalamp
10-15-2003, 08:15 PM
Yes, the code would be slightly different. A bit like this in fact:

owen_yuen
10-16-2003, 05:02 PM
Lavalamp:
First, I am really appreciate your times for your coding. Regarding the second TXT file. it seems like didn't work for the following rule. It maybe I was confused you from last example

Cannot contain more than two repeating characters
(e.g., "nn" is allowed, but "nnn" is not allowed).

Valid password: awqnn86nz

Invalid password: awnnnq86pz


I was read the information from
.http://javascriptkit.com/javatutors/re2.shtml . But I can't make it work for testing a string if more than two repeating characters.

No matter what, Thanks LOT!
Owen

lavalamp
10-16-2003, 07:05 PM
Oops, it looks as though this:

if(charcount>maxtogether-2){break;}

should have been this:

if(charcount>maxtogether-1){break;}

It should work now though:

owen_yuen
10-16-2003, 08:49 PM
Thanks, it works now!!!!

lavalamp
10-16-2003, 09:51 PM
Happy to help. :)

beetle
10-17-2003, 12:49 AM
Or, you can just use this :D

function check_pass( pass )
{
return ( /\d/.test( pass ) && !/(.)\1\1/.test( pass ) && pass.length >= 10 );
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum