How to force user to provide valid inputHi ,
I am trying to force the user to give a valid entry: I display a modal window, and ask to give a value.
If this value is a string different than "" , then the code should go on using the value given. If not , the script should hang on or prompt the user to give correct input.
I tried using a modal window + hiding the OK button, but somehow, it does not do the job (see attached code).
Please help.
win = New Window( "Set a Value",
<<MODAL></MODAL>
Re: How to force user to provide valid inputGreat !
it works perfectly.
Thans.
Re: How to force user to provide valid inputI prefer to explicitly use a Cancel button, but the design of your dialog is your business.
This modified version of the example I showed earlier should handle the case of the user clicking Cancel or the close window button.
Names Default to Here( 1 );
// put up dialog box for user entry
win = New Window( "Set a Value",
<<MODAL></MODAL>
Re: How to force user to provide valid inputHi @samir,
@Mark_Bailey has a really good starting point. I modified it slightly to what sounded like you were after -- the user entering a number.
Names Default To Here( 1 );
win = New Window( "Set a Value",
<<MODAL></MODAL>
You can also try the On Validate() option, but I think this returns a list of strings rather than a variable. In the above case, the new variable is "content", and could be passed to another function or JSL code that does something with it.
Also note, if you invoke the variablebox as a Number Edit Box, JMP knows not to allow anything but numbers, positive or negative. So, if they enter anything but a number, then the window stays open. I don't think it can handle imaginary numbers without a special add-in.
Hope this helps!,
DS
Re: How to force user to provide valid inputGreat !!!!
it does 99% of the job !
to be 100%, I need to do 2 modifications:
- comment out the code of the "cancel" button --> easy
- add something to exit the full code in case the user wants to cheat and clics on the "cross" symbol to close the modal window "win" without giving a string.
Do you know how to do this ?
Re: How to force user to provide valid inputTry this approach:
Names Default to Here( 1 );
win = New Window( "Set a Value",
<<MODAL></MODAL>