...

View Full Version : regular expressions for form validation



ClubCosmic
07-09-2005, 10:20 PM
I have the following code:


if (eregi ("([[:alnum:]]) ( ! | @ | # | $ | % | ^ | & | *) {6,12}$", $_POST['password1'])) {

I wanted to make sure the password contains alpha-numerics, some special chars, and was between 6 and 12 chars long. the code did work but now it doesn't.

see anything wrong with the syntax?
thanks in advance
c.c.

Kurashu
07-10-2005, 12:02 AM
preg_match('[^a-zA-Z0-9!@#\$%\^&\*]{6-12}', $password);

SHOULD work. But I'm not the sharpest stick in the box with a RegEx, so double check with someone.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum