saldous Posted February 23, 2007 Posted February 23, 2007 My code below is trying to do two things: 1) Check a password is more than 6 characters long and less than 15 characters long 2) Check that the PasswdInput and PAsswd2Input are the same (case sensivite) If neither of the two above are true then it should return to the GUI for the user to re-enter them again. But, my problem is that it always says the passwords don't match even when the user types them both in the same. I'm wondering if I need to split this out into two different While statements or not. Any advice appreciated as always. thank you. ; Start While loop to validate password length While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $NextButton2 $sRead = GUICtrlRead($PasswdInput) If StringLen($sRead) <= 15 And StringLen($sRead) >= 6 And ($PasswdInput == $Passwd2Input) Then ExitLoop If StringLen($sRead) > 15 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be less than 15 characters.') ElseIf StringLen($sRead) < 6 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be a minimum of 6 characters.') ElseIf Not ($PasswdInput == $Passwd2Input) Then MsgBox(262144 + 16, "Password Verification Failure", "Your passwords do not match - please try again") EndIf EndSwitch WEnd
Shevilie Posted February 23, 2007 Posted February 23, 2007 Try this ; Start While loop to validate password length While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $NextButton2 $sRead = GUICtrlRead($PasswdInput) If StringLen($sRead) <= 15 And StringLen($sRead) >= 6 And ($PasswdInput == $Passwd2Input) Then ExitLoop If StringLen($sRead) > 15 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be less than 15 characters.') ElseIf StringLen($sRead) < 6 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be a minimum of 6 characters.') ElseIf Not ($PasswdInput == $Passwd2Input) Then MsgBox(262144 + 16, "Password Verification Failure", "P1-" & $PasswdInput & "- P2-" & $Passwd2Input & "-") EndIf EndSwitch WEnd Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Shevilie Posted February 23, 2007 Posted February 23, 2007 Argh I get it.. you never read the two passwords You have to read them like you do when you read the length $sP1 = GUICtrlRead($PasswdInput) $sP2 = GUICtrlRead($Passwd2Input) If $sP1 == $sP2 Then Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
saldous Posted February 23, 2007 Author Posted February 23, 2007 Argh I get it.. you never read the two passwords You have to read them like you do when you read the length $sP1 = GUICtrlRead($PasswdInput) $sP2 = GUICtrlRead($Passwd2Input) If $sP1 == $sP2 Then Actually that is a bit higher up in my code, I only pasted that sample from it. Here is more if that helps: expandcollapse popup; Build 2nd page GUI $NextButton2 = GUICtrlCreateButton('&Next >>', 361, 288, 90, 30, BitOr($BS_DEFPUSHBUTTON, $BS_FLAT)) $FNameInput = GUICtrlCreateInput("", 273, 81, 185, 21) $SNameInput = GUICtrlCreateInput("", 273, 105, 185, 21) $EmailInput = GUICtrlCreateInput("", 273, 145, 185, 21) $PasswdInput = GUICtrlCreateInput("", 273, 185, 185, 21, $ES_PASSWORD) $Passwd2Input = GUICtrlCreateInput("", 273, 217, 185, 21, $ES_PASSWORD) $FName = GUICtrlCreateLabel("First Name", 185, 84, 54, 17) $SName = GUICtrlCreateLabel("Surname", 185, 111, 46, 17) $Email = GUICtrlCreateLabel("Email Address", 185, 149, 70, 17) $Passwd = GUICtrlCreateLabel("Password", 185, 189, 50, 17) $Passwd2 = GUICtrlCreateLabel("Confirm Password", 185, 221, 88, 17) $Note = GUICtrlCreateLabel("* Note: Your password must be a minimum of 6 characters. *", 176, 247, 286, 17) GUICtrlSetColor(-1, 0xFF0000) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) ; Set Max and Min character limits for Password entry GUICtrlSetLimit($PasswdInput, 15, 6); Max to 15, Min 6 characters GUICtrlSetLimit($Passwd2Input, 15, 6); Max to 15, Min 6 characters ; Start While loop to validate password length and that both passwords match While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $NextButton2 $sRead = GUICtrlRead($PasswdInput) If StringLen($sRead) <= 15 And StringLen($sRead) >= 6 And ($PasswdInput == $Passwd2Input) Then ExitLoop If StringLen($sRead) > 15 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be less than 15 characters.') ElseIf StringLen($sRead) < 6 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be a minimum of 6 characters.') ElseIf Not ($PasswdInput == $Passwd2Input) Then MsgBox(262144 + 16, "Password Verification Failure", "Your passwords do not match - please try again") EndIf EndSwitch WEnd
Shevilie Posted February 23, 2007 Posted February 23, 2007 Your still not READING the text... You have to read the text of the two inputs with GUICtrlRead ... look in the helpfile Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
saldous Posted February 23, 2007 Author Posted February 23, 2007 oh, I think I miss-read you, sorry. I only read the first password, not the second. I've adjusted my code and fixed it. Thanks for pointing me in the right direction. ; Start While loop to validate password length and that both passwords match While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $NextButton2 $sRead = GUICtrlRead($PasswdInput) $sRead2 = GUICtrlRead($Passwd2Input) If StringLen($sRead) <= 15 And StringLen($sRead) >= 6 And ($sRead == $sRead2) Then ExitLoop If StringLen($sRead) > 15 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be less than 15 characters.') ElseIf StringLen($sRead) < 6 Then MsgBox(262144 + 16, 'Password Length Error', 'Your password must be a minimum of 6 characters.') ElseIf Not ($sRead == $sRead2) Then MsgBox(262144 + 16, "Password Verification Failure", "Your passwords do not match - please try again") EndIf EndSwitch WEnd
Shevilie Posted February 23, 2007 Posted February 23, 2007 Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
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