...

View Full Version : checking for duplicate input



durangod
12-08-2010, 01:43 PM
on a password field i would like to prevent them from entering 00000 or xxxxx any char more than twice consecutively, i know there are names that are spelled with double o's so im thinking that twice is enough anything more than that would not be allowed.

i would like it to be set to check for more than twice consecutive and also more than 4x whole string..

i have all spaces coverd i just remove them, so im ok there but not sure how i would go about checking for the rest..

i know how to do value.indexof but i would have to give it an array to check correct? just not sure what function to use here..

maybe im going about this the wrong way here. the bottom line is i dont want anyone to be able to type in xxxxxx or 000000 or ...... or anything like that as a password..


update : maybe i can use count_chars function

jmace
12-08-2010, 10:58 PM
I think you want to use a regular expression.



if(preg_match('/(.)(?=\1{2})/i',$string)) die('You entered three or more of the same characters in a row!');


preg_match() uses a regular expression to search a string.

the (.) in the first part says store a character in the reference \1
the (?=\1{2}) tells it to look for two more of the same immediately following it
$string (the second parameter) would be your input

You might want to google regular expressions for more.


i would like it to be set to check for more than twice consecutive and also more than 4x whole string..
Not sure what you mean by that, but if you need more help let me know.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum