Archive: how to Disable "Next" button in nsDialogs if text field has no value


how to Disable "Next" button in nsDialogs if text field has no value
Hi,

I am using nsDialogs for making custom pages and i am stuck with one issue. I want to disable the next button if there is no value in the text. I have tried the solution suggested in other forum post but no success. below is my code.

Page Custom ServerChangesCreate ServerChangesLeave ""

Function ServerChangesCreate

nsDialogs::Create 1018
Pop $dialog

;Create a list box

${NSD_CreateLabel} 75 240 80 20 "Password"
${NSD_CreateText} 165 240 210 20 $R6
Pop $MPwd
${NSD_CreateLabel} 75 270 80 20 "MPort"
${NSD_CreateNumber} 165 270 210 20 $R7
Pop $MPort
${NSD_SetText} $MySQLPort 33307
${NSD_CreateLabel} 75 130 80 20 "Email"
${NSD_CreateText} 165 130 195 20 $R1
Pop $EmailField
nsDialogs::Show
FunctionEnd

Function ServerChangesLeave

${NSD_GetText} $MPort $R7
${Unless} ${TCPPortOpen} $R7
;MessageBox MB_OK "$R7 port is free"
${Else}
MessageBox MB_OK " Port $R7 is occupied by some other process, please specify a different port "
Abort
${EndIf}
${NSD_GetText} $MPwd $R6
${NSD_GetText} $EmailField $R1
FunctionEnd

So you can see i am using three different text field, in password field i want normal validation of the text.
In email field it should have a proper email, we can check with the help of @.

Please help me out as i am stuck with this.


GetDlgItem $NextButton $HWNDPARENT 1 ; next=1, cancel=2, back=315

GetDlgItem $NextButton $HWNDPARENT 1 ; next=1, cancel=2, back=315
${NSD_CreateText} 165 240 210 20 $R6
Pop $MPwd
${NSD_OnChange} $MPwd OnChange_MPwd


in that onchange function you can use NSD_GetText as you did before and hide/show the button as desired

Function OnChange_MPwd
Pop $0
${NSD_GetText} $MPwd $0
${If} $0 == ""
EnableWindow $NextButton 0
${Else}
EnableWindow $NextButton 1
${EndIf}
FunctionEnd


parsing for a valid email address should be possible using a combination WordFind and other headers

Originally posted by Yathosho
parsing for a valid email address should be possible using a combination WordFind and other headers
http://nsis.sourceforge.net/Email_Validation_Function

hi Yathosho thank you for quick reply, i made the changes suggested by you but it is still not disabling the field.


i don't know why it's not working for you. i've attached a working example, maybe it helps you to figure it out.


thank you very much Yathosho and Animaether for helping me. I got the mistake which i was doing. You guys rock.