linus72982 Posted March 4, 2011 Share Posted March 4, 2011 I am building a new site for forums that has a high population of old people and they wouldn't appreciate me not allowing their simple passwords, so I search and search and everything I found on google requires complexity. So, if anyone can help with a regex that does the following, I'd appreciate it: 1. Can contain only letters, numbers, and symbols (just the normal symbols, no unicode or slashes, etc) 2. Cannot contain spaces 3. Must be 8-16 characters in length That's it, no other complexity required. Thanks for any help. Quote Link to comment Share on other sites More sharing options...
.josh Posted March 5, 2011 Share Posted March 5, 2011 Well, since you didn't really fully define what you consider to be "normal" symbols, this regex will only accept letters, numbers and any of the symbols above the numbers on your keyboard. if (preg_match('~^[a-z0-9!@#\$%\^&\*\(\)]{8,16}$~i',$password)) { // valid } else { // invalid } Quote Link to comment Share on other sites More sharing options...
linus72982 Posted March 5, 2011 Author Share Posted March 5, 2011 Thanks, and yes, I meant just the symbols on the number keys. I'll try it out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.