<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to force user to provide valid input in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251563#M49401</link>
    <description>&lt;P&gt;I prefer to explicitly use a Cancel button, but the design of your dialog is your business.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This modified version of the example I showed earlier should handle the case of the user clicking Cancel or the close window button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

// put up dialog box for user entry
win = New Window( "Set a Value", 
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;Return Result, 
	tb = Text Box( "Set this value" ), 
	variablebox = Text Edit Box( "",
		&amp;lt;&amp;lt; Set Function(
			Function( { me },
				content = me &amp;lt;&amp;lt; Get Text;
				If( Is Missing( content ),
					bb &amp;lt;&amp;lt; Enable( 0 ),
					bb &amp;lt;&amp;lt; Enable( 1 )
				)
			)
		)
	), 
	bb = Button Box( "OK",
		&amp;lt;&amp;lt; Enable( 0 ),
		content = bb &amp;lt;&amp;lt; Get Text;
	),
	Button Box( "Cancel" ),
);

// unload dialog
If( win["Button"] == -1, Throw( "User cancelled" ) );

// continue with remainder of script
Show( content );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 10 Mar 2020 16:26:18 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2020-03-10T16:26:18Z</dc:date>
    <item>
      <title>How to force user to provide valid input</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251456#M49369</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I am trying to force the user to give a valid entry: I display a modal window, and ask to give a value.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;I tried using a modal window + hiding the OK button, but somehow, it does not do the job (see attached code).&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;win = New Window( "Set a Value", 

	&amp;lt;&amp;lt;Modal,

	&amp;lt;&amp;lt;Return Result, 

	tb = Text Box( "Set this value" ), 

	variablebox = Text Edit Box( "", 
		//bb &amp;lt;&amp;lt; enable(variablebox &amp;lt;&amp;lt; get text !="");
		If( variablebox &amp;lt;&amp;lt; get text != "",
			bb &amp;lt;&amp;lt; Visibility( "Visible" )
		),

	), 

	bb = Button Box( "OK" ),
	bb &amp;lt;&amp;lt; Visibility( "Hidden" ),
	If( variablebox &amp;lt;&amp;lt; get text != "",
		bb &amp;lt;&amp;lt; Visibility( "Visible" ),
		bb &amp;lt;&amp;lt; Visibility( "Hidden" )
	), 

	//Button Box( "Cancel" ),
	
	

);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 06:36:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251456#M49369</guid>
      <dc:creator>samir</dc:creator>
      <dc:date>2020-03-10T06:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to force user to provide valid input</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251484#M49377</link>
      <description>&lt;P&gt;Try this approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

win = New Window( "Set a Value", 

	&amp;lt;&amp;lt;Modal,

	&amp;lt;&amp;lt;Return Result, 

	tb = Text Box( "Set this value" ), 

	variablebox = Text Edit Box( "",
		&amp;lt;&amp;lt; Set Function(
			Function( { me },
				content = me &amp;lt;&amp;lt; Get Text;
				If( Is Missing( content ),
					bb &amp;lt;&amp;lt; Enable( 0 ),
					bb &amp;lt;&amp;lt; Enable( 1 )
				)
			)
		)
	), 

	bb = Button Box( "OK",
		&amp;lt;&amp;lt; Enable( 0 ),
		content = bb &amp;lt;&amp;lt; Get Text;
	),
	Button Box( "Cancel" ),

);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:46:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251484#M49377</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-03-10T12:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to force user to provide valid input</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251518#M49387</link>
      <description>&lt;P&gt;Great !!!!&lt;/P&gt;&lt;P&gt;it does 99% of the job !&lt;/P&gt;&lt;P&gt;to be 100%, I need to do 2 modifications:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;comment out the code of the "cancel" button --&amp;gt; easy&lt;/LI&gt;&lt;LI&gt;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.&lt;BR /&gt;Do you know how to do this ?&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 10 Mar 2020 14:02:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251518#M49387</guid>
      <dc:creator>samir</dc:creator>
      <dc:date>2020-03-10T14:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to force user to provide valid input</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251553#M49396</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/395"&gt;@samir&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;has a really good starting point. I modified it slightly to what sounded like you were after -- the user entering a number.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
win = New Window( "Set a Value",
	&amp;lt;&amp;lt;Modal, 
	//&amp;lt;&amp;lt;Return Result,
	Text Box( "Set this value" ),
	variablebox = Number Edit Box(
		.,
		&amp;lt;&amp;lt;Set Function(
			Function( {my_value},
				content = my_value &amp;lt;&amp;lt; Get;
				If( Is Missing( content ),
					bb &amp;lt;&amp;lt; Enable( 0 ),
					bb &amp;lt;&amp;lt; Enable( 1 )
				);
			)
	
		)
	),
	bb = Button Box( "OK",&amp;lt;&amp;lt; Enable( 0 ), content = bb &amp;lt;&amp;lt; Get );
);
Print("Value is "|| Char(content) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!,&lt;/P&gt;&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 15:46:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251553#M49396</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2020-03-10T15:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to force user to provide valid input</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251563#M49401</link>
      <description>&lt;P&gt;I prefer to explicitly use a Cancel button, but the design of your dialog is your business.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This modified version of the example I showed earlier should handle the case of the user clicking Cancel or the close window button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

// put up dialog box for user entry
win = New Window( "Set a Value", 
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;Return Result, 
	tb = Text Box( "Set this value" ), 
	variablebox = Text Edit Box( "",
		&amp;lt;&amp;lt; Set Function(
			Function( { me },
				content = me &amp;lt;&amp;lt; Get Text;
				If( Is Missing( content ),
					bb &amp;lt;&amp;lt; Enable( 0 ),
					bb &amp;lt;&amp;lt; Enable( 1 )
				)
			)
		)
	), 
	bb = Button Box( "OK",
		&amp;lt;&amp;lt; Enable( 0 ),
		content = bb &amp;lt;&amp;lt; Get Text;
	),
	Button Box( "Cancel" ),
);

// unload dialog
If( win["Button"] == -1, Throw( "User cancelled" ) );

// continue with remainder of script
Show( content );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 16:26:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251563#M49401</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-03-10T16:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to force user to provide valid input</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251718#M49427</link>
      <description>&lt;P&gt;Great !&lt;/P&gt;&lt;P&gt;it works perfectly.&lt;/P&gt;&lt;P&gt;Thans.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 05:37:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-force-user-to-provide-valid-input/m-p/251718#M49427</guid>
      <dc:creator>samir</dc:creator>
      <dc:date>2020-03-11T05:37:42Z</dc:date>
    </item>
  </channel>
</rss>

