Archive: How to stay on a custom page if input is not valid


How to stay on a custom page if input is not valid
I have created a custom page for a user to enter the name of the website to create in IIS, the installer then creates the specified web site and install files to it.

If the user has not entered a value, I would like to display an error message and remain on the custom page for the user to try again.

I have managed the validation, but I tried calling the function to create my custom page again and it displayed but the back / next / cancel buttons of the installer were disabled.

Script snippet below:

Function WebsitePagePre ; gather the name of the website to create in IIS, do not allow a blank value StrCmp $1 "" 0 +3 MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter a name for the website in IIS." idok noabort noabort: Call WebsitePage FunctionEnd

Sorry code is as follows:

Function WebsitePagePre
# Form validation here. Call Abort to go back to the page.
# Use !insertmacro MUI_INSTALLOPTIONS_READ $Var "InstallOptionsFile.ini" ...
# to get values.

; gather the name of the website to create in IIS, do not allow a blank value
!insertmacro INSTALLOPTIONS_READ $1 "createwebsite.ini" "Field 3" "State"
StrCmp $1 "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter a name for the website in IIS." idok noabort
noabort:
Call WebsitePage

FunctionEnd


call abort in the leave function.


Cannot get this to work as intended. I added a page leave function and called abort but this does not leave the user on the same page. Also, if I enter data into the textbox and click Next, nothing is getting installed!

Code below:

Page custom WebsitePage
!define MUI_PAGE_CUSTOMFUNCTION_PRE WebsitePagePre
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE WebsitePageLeave

Function WebsitePagePre
# Form validation here. Call Abort to go back to the page.
# Use !insertmacro MUI_INSTALLOPTIONS_READ $Var "InstallOptionsFile.ini" ...
# to get values.

; gather the name of the website to create in IIS, do not allow a blank value
!insertmacro INSTALLOPTIONS_READ $1 "createwebsite.ini" "Field 3" "State"
StrCmp $1 "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter a name for the website in IIS."

FunctionEnd

Function WebsitePageLeave
abort
FunctionEnd


Define the pre and leave BEFORE the page. Read the field values in the LEAVE function, not the pre.

This information is all in the documentation. You should read it before trying to do things.