【问题标题】:Validate text box input before continuing在继续之前验证文本框输入
【发布时间】:2011-10-06 16:46:22
【问题描述】:

我有一个包含文本框的自定义对话框页面。当用户点击“下一步”按钮时,我想确保文本框中有文本,然后才能继续安装。

如何做到这一点?我尝试在 nsDialogsPageLeave 中添加一个检查,如果验证失败,我会在其中调用 nsDialogsPage,但这不起作用...页面底部的按钮在重新加载后无效。

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

【问题讨论】:

    标签: textbox dialog nsis nsdialogs


    【解决方案1】:

    我处理这种情况的方法是验证 leave 函数中的文本,以便您的代码变为:

    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
    

    这样,用户可以单击“下一步”按钮,但如果没有输入任何文本,他们将收到一条错误消息,并且“中止”将停止安装程序移动到下一页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 1970-01-01
      • 2017-06-24
      • 1970-01-01
      • 2015-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多