Universal Robots Forum

Validating user inputs

Hi everybody,

Is there a way of validating user input using standard Polyscope API functionality? I’d like to display a dialog like this one when the user enters an invalid value according to some criteria:

I know this can be done by performing the check manually during the callback of an InputText for example; I just wanted to know if there’s a standard way of doing so.

Thanks in advance!

Depending on the number of correct responses I have done switch statements and used the default case to return back to the question when they did not answer using one of the correct responses. Have also done value checking to ensure the value is between limits to know that its a useable value. None of this is built-in as standard that I am aware of but that also means you have the flexibility to do the error checking the best way for your particular use case. We just wrap it in a loop with a flag called goodChoice. As long as goodChoice is false we keep coming back to the question, upon a succesful answer we set the flag true and move on

1 Like

For number input fields, you have the fixed HTML value range.
Meaning that you can use the min="0" and max="15" tags in your HTML, to restrain numeric input.
E.g. like this example from the UR3 Screw sample:

<input id="torque" type="number" min="0" max="12" size="10">

This will limit the allowed input range and show a generic error message:

However having the ability to check the input dynamically from any field from Java, and show a custom error message would be a feature request.
I would suggest adding this to the Feature Request category.

2 Likes

Thanks for the answers!
I didn’t know those “min”, “max” and “size” were allowed; I couldn’t find them in the appendix of the URCap tutorial PDF.
Perhaps a good feature request then would be to have the capability to modify those attributes from the Java side of the application.

In my case, I’m using the same textbox as different types of inputs according to a given condition, so I need to validate numbers or strings depending on some dynamic condition. I know I could also use different text boxes and show/hide them accordingly, but that makes the UI flicker for a short moment. If I could modify those attributes, that would do perfectly!