开发者

Validate text box input before continuing

开发者 https://www.devze.com 2023-04-11 11:09 出处:网络
I have a custom dialog page that contains a text box.When the user hits the \"Next\" button, I want to make sure that there is text in the text box before allowing the installation to continue.

I have a custom dialog page that contains a text box. When the user hits the "Next" button, I want to make sure that there is text in the text box before allowing the installation to continue.

How can this be done? I tried adding a check in nsDialogsPageLeave, where I call nsDialogsPage if the validation fails, but this does not work...the buttons at the bottom of the page are not active after it reloads.

Var Dialog
Var Text
Var Text_State

Page custom nsDialogsPage nsDialogsPageLeave



Function nsDialogsPage

nsDialogs::Create 1018
Pop $Dialog

${If} $Dialog == error
    Abort
${EndIf}

${NSD_CreateText} 0 0 50% 12u $Text_State
Pop $Text

nsDialogs::Show

FunctionEnd



Function 开发者_运维百科nsDialogsPageLeave

${NSD_GetText} $Text $Text_State

FunctionEnd


The way I've dealt with this situation is to validate the text in the leave function so that your code becomes:

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateText} 0 0 50% 12u $Text_State
    Pop $Text

    nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

    ${NSD_GetText} $Text $Text_State

    ${If} $Text_State == ""
        MessageBox MB_OK "Please enter some text"
        Abort
    ${EndIf}

FunctionEnd

This way the user can click the Next button but they will get an error message if no text has been entered and the Abort will stop the installer moving to the next page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号