Archive: Validating User Input


Validating User Input
  Hello again :)

I've been trying to determine how I can validate some data entered by the users using the Modern UI to ensure that the user enters something in a required field. I thought about using the .onNextPage event, but it doesn't seem to work. Does the .onNextPage event only work with the normal UI or am I just doing something wrong? When I compiled the script MakeNSIS displayed a warning: install function ".onNextPage" not referenced. I'm sure that this is why it isn't using the function in the script. Anyone have any idea what could be causing this? I've searched thru the examples and haven't found anything that might cause this with my script. Could it be because I'm using custom pages?

Thanks


Hmm, I might have found something that would help me out. I got bored and started aimlessly wandering topics. I managed to find it on something completely irrelevant to it, but oh well.

http://nsis.sourceforge.net/archive/....php?pageid=87


Well I couldn't figure it out and I got some other things to do yet. If anyone has anything of a simple validation for custom pages let me know please.


Use


!define MUI_CUSTOMFUNCTION_WELCOME_SHOW "Validate"

Where "Validate" is your function (which you currently have as .onNextPage)
If your custom page is before the InstFiles page, then change it to...

!define MUI_CUSTOMFUNCTION_INSTFILES_SHOW "Validate"

etc.

-Stuart

Ah, thanks for the help Stuart, now I just need to figure out how to stop it from changing pages :)


That's wrong with the archive page? It shows you how to validate.

After the IO call, validate when the return value is success and go back to the call if the input is wrong.

Use the MUI_INSTALLOPTIONS_DISPLAY_RETURN macro to be able to get the return value from the stack.


.onNextPage and .onPrevPage no longer exist in NSIS 2. According to your original question the answer is very simple, just use MinLen=1 in the INI file. For example:


***93;

>Type=Text
Left
=10
Right=-10
Top=90
Bottom=98
MinLen=1
>
This will cause IO to display an error message if the user is trying to exit the page when this control has less than 1 characters in it, which means zero characters, nothing.

To change the error message use ValidateText in [Field *].

Nice one KiCHiK :)

/me goes and adds it to my IO ini files...


-Stuart


Well that explains quite a bit about why .onNextPage didn't work. And thanks for that tip about MinLen kichik. That should do it :)