Archive: Disable "Next" button while user input is incorrect


Disable "Next" button while user input is incorrect
Hi, I`m new in NSIS and I have a following problem:
on a custom page with user input field I must disable the "Next" button while the inputed word`s length is less then 3
or more then 10.

PS If its not hard to you, please wtite some script example or something.


Hopefully you are using nsDialogs for your custom page. If so, assign an onChange event to your control. In the callback, check the length of the input (using StrLen) and enable/disable the button accordingly. (If this is confusing, review the nsDialogs documentation.)

Assuming $1 is the user's text, your code might looks something like this: (This uses LogicLib, so be sure to include LogicLib.nsh at the top of your script):

StrLen $2 "$1"
GetDlgItem $0 $HWNDPARENT 1 ; next=1, cancel=2, back=3
${If} $2 < 3
${OrIf} $2 > 10
EnableWindow $0 0
${Else}
EnableWindow $0 1
${EndIf}


edit: added ${OrIf} to catch greater than 10