Archive: Validation


Validation
Hi, I have a custom page that asks for registration info, if the user enters the wrong stuff, a message box comes up and says "incorrect registration ID"

...the problem is..when the user clicks the cancel button...it asks if they want to exit...they click Yes, but then for some reason it seems the validation function is run again, and that message box comes up...and won't let them exit unless they click back


Let me guess...

Page Custom ShowFunc LeaveFunc

You are validating the page in the ShowFunc when it must be done in the LeaveFunc. The LeaveFunc is only called when the user clicks Next.

-Stu


Actually it's
Page custom RegistrationPage CheckID

CheckID is the validation code, I'm using that ExperienceUI, but I didn't think that would have anything to do it with it. ..It also only occurs when you enter an invalid key once, and then try to exit. If you simply go to the registration page..and click cancel..it exits...but if you go to the page, enter an invalid key..try it (displays error)...then try to exit...it won't let you.

I am using a custom made .dll for this? could this be the reason?


Did you make your own plugin to display this page?

Edit: In plugin DLL's you need to do validation when the WM_NOTIFY_OUTER_NEXT message is sent to the window procedure.

-Stu


thanks alot for helping me out Afro UK

hrmmmm...

I have a function in my DLL called check, all it does is check to see if the CD KEY is valid from a webserver, and returns a string telling if it's correct or incorrect..


SetPluginUnload alwaysoff ;don't know what this means
System::Call 'Dll::CheckID(t, i) i("${REGID}", "4") .r0'
System::Free 0
SetPluginUnload manual ;nor this...read it in a tut on wiki


So I'm guessing the WM_NOTIFY_OUTER_NEXT doesn't apply to me here right?

Ah I see. No it doesn't.
Would you be able to post the code in question?
If not then you can send it via PM.

-Stu


I always feel embarressed to post my code, but here we go..


Function CheckID

ReadINIStr ${TEMP1} "$PLUGINSDIR\reg.ini" "Field 4" "State"

SetPluginUnload alwaysoff
System::Call 'Dll::CheckID(t, i) i("${TEMP1}", "4") .r0'

StrCmp $0 "1" done
StrCmp $0 "2" incorrect
StrCmp $0 "3" toomany
System::Free 0
SetPluginUnload manual

Goto done

incorrect:
MessageBox MB_ICONEXCLAMATION|MB_OK "Incorrect Registration ID"
Abort

toomany:
MessageBox MB_ICONEXCLAMATION|MB_OK "This Registration ID has been used too many times. Please call 800-999-9999"
Abort

done:

FunctionEnd


I realize this is probably very inefficent with and terrible practice with these goto statements (might be the cause of the problem) but I can't seem to get the !if statements to work properly when using StrCmp as it doesn't seem to return true or false..it GOTOs somewhere if it's equal or GOTOs somewhere if it's not equal...so by all means if someone could post a better way, that would be great.

I can also post the rest if you don't think that this function is the cause of the problem..

Try this:


Function CheckID

ReadINIStr ${TEMP1} "$PLUGINSDIR\reg.ini" "Field 4" "State"

System::Call /NOUNLOAD 'Dll::CheckID(t, i) i("${TEMP1}", "4") .r0'

StrCmp $0 "1" done
StrCmp $0 "2" incorrect
StrCmp $0 "3" toomany

incorrect:
MessageBox MB_ICONEXCLAMATION|MB_OK "Incorrect Registration ID"
Abort

toomany:
MessageBox MB_ICONEXCLAMATION|MB_OK "This Registration ID has been used too many times. Please call 800-999-9999"
Abort

done:

FunctionEnd


LogicLib uses Goto and labels behind the scenes, so your code is already as good as it can possibly be :)

-Stu

Still same thing. I push cancel..it gives me a confirmation box. I click 'yes I want to exit' and then it gives me the error message (the exact error message it would as if I clicked next)..

I'm wondering why the validation function is even running when I push Cancel? There isn't a way I can dig a bit deaper in here and actually handle the button events can I?


Perhaps you could attach your entire script (as a file attachment) as there must be something else at fault here.

-Stu


Function CheckID

ReadINIStr $0 "$PLUGINSDIR\reg.ini" "Settings" "State"
StrCmp $0 0 0 done

ReadINIStr ${TEMP1} "$PLUGINSDIR\reg.ini" "Field 4" "State"

System::Call /NOUNLOAD 'Dll::CheckID(t, i) i("${TEMP1}", "4") .r0'

StrCmp $0 "1" done
StrCmp $0 "2" incorrect
StrCmp $0 "3" toomany

incorrect:
MessageBox MB_ICONEXCLAMATION|MB_OK "Incorrect Registration ID"
Abort

toomany:
MessageBox MB_ICONEXCLAMATION|MB_OK "This Registration ID has been used too many times. Please call 800-999-9999"
Abort

done:

FunctionEnd

That's just Function CheckID...

-Stu


Originally posted by Afrow UK
That's just Function CheckID...
... which performs check only if "Next" is pressed, and not every time the page leave is triggered.

Yes, but that isn't the entire script. There's nothing wrong with that function.

If you do not wish to post your entire script then you can E-mail it to me at afrowuk at tiscali dot co dot uk.

-Stu


I think I had the same problem at one time with XPUI.

If memory serves me, when using ExperienceUI and using an XPUI_ABORTWARNING, you must also include an abort page. (Have a look at the documentation.)

If not using XPUI_ABORTWARNING, then you must use code such as this to close the install when the user clicks on cancel:


Function .onUserAbort
StrCmp $NOABORTWARNING 1 CloseMe
MessageBox MB_YESNO|MB_ICONQUESTION "Are you sure you want to cancel Setup?" IDNO NoAbort
# any custom code you want before the Abort page is called here...
!insertmacro XPUI_USERABORT
NoAbort:
Abort
CloseMe:
# any custom code you want before the installer exits here...
FunctionEnd

Originally posted by Afrow UK
Yes, but that isn't the entire script. There's nothing wrong with that function.

If you do not wish to post your entire script then you can E-mail it to me at afrowuk at tiscali dot co dot uk.

-Stu
WTF dude. I'm not the one asking question.
I posted a solution.
As for "nothing wrong", well, if that function is set as custom leave, unless you add the additional check to see what invoked it, it would try to calculate the ID every time it's invoked (including when user press the Cancel button, and when any control, which has notify flag set, has it's state changed).

lol Afrow UK must mean the question was for kgobel, not for galil.

One thing I have noticed:


ReadINIStr ${TEMP1} "$PLUGINSDIR\reg.ini" "Field 4" "State"

System::Call /NOUNLOAD 'Dll::CheckID(t, i) i("${TEMP1}", "4") .r0'

Shouldn't ${TEMP1} be a variable? Because this is refering to a define. Try using a variable instead, like $1:

ReadINIStr $1 "$PLUGINSDIR\reg.ini" "Field 4" "State"

System::Call /NOUNLOAD 'Dll::CheckID(t, i) i(.r1, "4") .r0'

[edit]This is probably the first time I have troubleshooted a problem with the system plugin, and the first time I have read the system documentation :) .[/edit]

galil, the Leave function is only called when the user clicks the Next button (or as you rightly say, if the NOTIFY flag is used on a control).

Jason, I think kgobel is just using TEMP1 as a define for a variable, much like MUI used to use !define MUI_TEMP1 $0 before the Var instruction was introduced.

I've never used XPUI so I'm with Comperio now :)

-Stu