EndFunc Posted November 28, 2009 Posted November 28, 2009 (edited) Ok so i've used some samples I found on the forum to help create me a password complexity checker.Now, problem is I want to be able to allow either a number OR a symbol. However the script keeps requiring both. What am I doing wrong?Here is a snippet of the code where it does it. The line with the OR in it close to the bottom.Func CheckPWD() If StringRegExp($passwd,'[a-z]') = "0" Then ;// [verified] at least one lower case letter Msgbox(16, $AppName, $Error_Message, 10) GUICtrlSetData($Password, "") GUICtrlSetData($Confirm, "") WinActivate("Set Account Password") GUICtrlSetState($Password, $GUI_FOCUS) SetError(1) Return ElseIf StringRegExp($passwd,'[A-Z]') = "0" Then ; // [verified] at least one upper case letter Msgbox(16, $AppName, $Error_Message, 10) GUICtrlSetData($Password, "") GUICtrlSetData($Confirm, "") WinActivate("Set Account Password") GUICtrlSetState($Password, $GUI_FOCUS) SetError(1) Return ElseIf StringRegExp($passwd,'\d+') = "0" OR StringRegExp($passwd,'[!,@,#,$,%,^,&,*,?,_,~]') = "0" Then ;// [verified] at least one number Msgbox(16, $AppName, $Error_Message, 10) GUICtrlSetData($Password, "") GUICtrlSetData($Confirm, "") WinActivate("Set Account Password") GUICtrlSetState($Password, $GUI_FOCUS) SetError(1) Return EndFunc Edited November 28, 2009 by EndFunc EndFuncAutoIt is the shiznit. I love it.
Authenticity Posted November 28, 2009 Posted November 28, 2009 Maybe using And: Local $passwd = "!1aA", $AppName = "AppName", $Error_Message = "Weak" CheckPWD() Func CheckPWD() If StringRegExp($passwd,'[a-z]') = 0 Then ;// [verified] at least one lower case letter Msgbox(16, $AppName, $Error_Message, 10) Return SetError(1) ElseIf StringRegExp($passwd,'[A-Z]') = 0 Then ; // [verified] at least one upper case letter Msgbox(16, $AppName, $Error_Message, 10) Return SetError(1) ElseIf StringRegExp($passwd,'\d+') = 0 And StringRegExp($passwd,'[!@#$%^&*?_,~]') = 0 Then ;// [verified] at least one number Msgbox(16, $AppName, $Error_Message, 10) Return SetError(1) Else MsgBox(0x30, $AppName, "Nice", 10) EndIf EndFunc
Malkey Posted November 28, 2009 Posted November 28, 2009 (edited) And another example without "And" or "Or".Local $passwd = "aB3" MsgBox(0, "AppName", CheckPWD($passwd), 8) Func CheckPWD($passwd) Local $Error_Message = "" If StringRegExp($passwd, '[a-z]') = 0 Then $Error_Message = "At least one lower case letter missing" & @CRLF ;// [verified] at least one lower case letter If StringRegExp($passwd, '[A-Z]') = 0 Then $Error_Message &= "At least one upper case letter missing" & @CRLF ; // [verified] at least one upper case letter If StringRegExp($passwd, '[!@#$%^&*?_,~\d]') = 0 Then $Error_Message &= "At least one number or symbol missing" & @CRLF;// [verified] at least one number If $Error_Message = "" Then $Error_Message = "Password acceptable" Return $Error_Message EndFunc ;==>CheckPWDEdit: Changed '[!,@,#,$,%,^,&,*,?,_,~\d]' to '[!@#$%^&*?_,~\d]'. One coma within square brackets is enough. Edited November 28, 2009 by Malkey
EndFunc Posted November 28, 2009 Author Posted November 28, 2009 Thanks both. Seems so simple now. lol. I didn't know you could combine them as well. Nice. EndFuncAutoIt is the shiznit. I love it.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now