Expand my Community achievements bar.

lock fields, so that they cannot be reset

Avatar

Level 1

I'm looking for a way to lock the value of a field, so that it cannot be reset.

I think it must be done with Variables, but i don't know how.

What is the best way to prevent a field from resetting?

Can anyone help me with this.

3 Replies

Avatar

Level 7

Do you mean that you don't want to modify the variable with your code, too? Or just that you don't want a user to modify it?

If you're trying to make sure that you don't modify it with your code, then you can create a variable to temporarily store the value, then put it back after the reset.

If you're just trying to keep the user from messing with it, you can set it to read only after you receive it. tfExample.access = "readOnly"; should work for that in JavaScript.

Avatar

Level 1

I have a form that has several fields that need to be pretected after clicking a button.

So the user cannot alter the imput and cannot reset those fields.

For the normal fields i've used Variables and put a FormCalc script to the 'Exit' event:

And a FormCalc script to the 'layout:ready' event:

But i also have a table with 2 textfields and a button to add more rows.

How do i protect those tablefields from altering and resetting?

Avatar

Level 7

Something like this will work:

if (HasValue($)) then

     vYear.rawValue = $.rawValue

     vYear.access = "protected"

else

     vYear.rawValue = ""

     vYear.access = "open"

endif

That will cause whatever field has this code to protect another field and give it the same value if it isn't empty, and clear/open the field if it is.