9

I have a Wix dialog with a control of type edit (which is a uri of a server the service depends on).

How can I disable the Next button until a value has been input?

NotDan
  • 31,709
  • 36
  • 116
  • 156

2 Answers2

11

Here's an excerpt from some (old) production code we used to use:

<Dialog Id="MyDlg_Error" Width="260" Height="85" NoMinimize="yes" Title="!(loc.MyDlg_Title)">
    <Control Id="MyDlgSkipDesc" Type="Text" Width="194" X="48" Y="15" Height="30" Text="!(loc.MyDlg_ErrorMsg)" />
    <Control Id="Ok" Type="PushButton" X="97" Y="57" Width="66" Height="17" Text="!(loc.WixUIOK)" />
</Dialog>

<Publish Dialog="MyDlg" Control="Next" Event="SpawnDialog" Value="MyDlg_Error"><![CDATA[Not (MY_REQUIRED_FIELD <> "")]]></Publish>

<Publish Dialog="MyDlg_Error" Control="Ok" Event="EndDialog" Value="Return">1</Publish>
saschabeaumont
  • 22,080
  • 4
  • 63
  • 85
  • 1
    And then you should add the opposite condition (e.g. `<![CDATA[(MY_REQUIRED_FIELD <> "")]]>`) on the `NewDialog` event, so it doesn't move to the next page in this case. – Tsahi Asher Apr 25 '17 at 15:13
3

There's no reasonable way to do that. Instead, leave Next enabled and do your check with a SpawnDialog control event tied to Next that shows an error if the property is empty. It also lets you run a validation custom action if you want something more useful that "not empty."

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
  • 2
    That's not a problem doing it on the Next click, where can I find an example of how to do that? – NotDan Apr 04 '11 at 01:35