TTMP Posted December 29, 2007 Share Posted December 29, 2007 First I would like to say hi to everyone here and ask the experts to please give me some guidance with this issue I'm having validating a password. I have googled this and tried every possible but for some reason nothing seems to work the right way. What I need is the password can be in any order but has to have these requirements: Minimum of 8 characters. Maximum of 20 characters. At least one lower case letter. At least one upper case letter. At least one number. And at least one of these ~!@#$%^&*()_+ special characters. I have tried many solutions for this and everytime it allows passwords that do not meet these requirements. If someone could help me with this I would really appreciate it. Thank you in advance. Quote Link to comment Share on other sites More sharing options...
raku Posted December 30, 2007 Share Posted December 30, 2007 Hi, For the 8-20 character limit you can use a simple length comparison. For the lower and upper case letters, you can convert the password string using one of php's functions into an all lowercase form. If this form equals the original, then you know that the user did not enter any uppercase letters. You can use another function to convert it to an all uppercase form. I think these functions are strtoupper() and strtolower(). For the numbers and special characters, you can use a simple regular expression. Hope this helps. Quote Link to comment Share on other sites More sharing options...
TTMP Posted December 30, 2007 Author Share Posted December 30, 2007 Thanks raku for your response. I did use your solution and it does work the way i want it to finally. Thank you very much for your help. 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.