Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create an input field that handles erroneous inputs gracefully and responds to the Enter/Return key
ResourceFunction["ValidatedInputField"][Dynamic[var],test,msg] creates an editable input field with dynamically updated field value var, that performs a validity check for the input using test and shows msg in case the test fails. | |
ResourceFunction["ValidatedInputField"][Dynamic[var],test,msg,action] creates an input field that performs action when Enter/Return is pressed. |
Create an input field that accepts a number between 0 and 10; trying to enter a value outside the range will result in an error message:
| In[1]:= | ![]() |
| Out[1]= |
An input field that prints the current number upon hitting Enter/Return:
| In[2]:= | ![]() |
| Out[2]= |
Change the appearance:
| In[3]:= | ![]() |
| Out[3]= |
Set the baseline position:
| In[4]:= | ![]() |
| Out[4]= |
Disable the input field:
| In[5]:= |
| Out[5]= |
Mask the contents:
| In[6]:= | ![]() |
| Out[6]= |
Set a larger frame margin:
| In[7]:= | ![]() |
| Out[7]= | ![]() |
Set a larger image margin:
| In[8]:= | ![]() |
| Out[8]= | ![]() |
Alter the field size:
| In[9]:= | ![]() |
| Out[9]= |
Alter the image size:
| In[10]:= | ![]() |
| Out[10]= | ![]() |
Show an error dialog when an entered value for a plot range is not a number or is less than zero:
| In[11]:= | ![]() |
| Out[11]= | ![]() |
Show an error dialog when an entered radius is not a number between 1 and 2:
| In[12]:= | ![]() |
| Out[12]= | ![]() |
The built-in InputField responds to Enter/Return only when the value is changed. The following prints the value in the input field for a new value only:
| In[13]:= | ![]() |
| Out[13]= |
ValidatedInputField alleviates this limitation by printing the value whenever Enter/Return is pressed:
| In[14]:= | ![]() |
| Out[14]= |
This work is licensed under a Creative Commons Attribution 4.0 International License