Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Lock a specific Text Field

Anonymous
Not applicable

I have a Text Field which gets populated with random numbers every time the form is opened.

I would like to add a button using JavaScript which will lock only that Text Field when clicked after form was rendered so that the number remain static when opening and closing the form.

4 Replies
jasotastic81
Level 7
Level 7

I'm sure you could modify this for your purposes, but here's my solution with a checkbox instead of a button.

780726_pastedImage_0.png

So, if that box is checked when the form is saved, the text field will not generate a random number when the form is opened again.

Anonymous
Not applicable

Add the following script on the initialize event of the textfield that should get locked.

if(this.rawValue !=  nul)

     this.access = "protected";

Thanks

radzmar
Level 10
Level 10

Hi,

the previous script contains a typo and won't work.

Try this script instead.


this.access = this.isNull ? "open" : "protected";


Anonymous
Not applicable

Thanks Radzmar