Lock a specific Text Field

Avatar

Avatar

new_bee_03

Avatar

new_bee_03

new_bee_03

25-06-2015

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.

Accepted Solutions (0)

Answers (4)

Answers (4)

Avatar

Avatar

radzmar

MVP

Avatar

radzmar

MVP

radzmar
MVP

26-06-2015

Hi,

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

Try this script instead.


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


Avatar

Avatar

alcdtrainer1

Avatar

alcdtrainer1

alcdtrainer1

07-07-2015

Thanks Radzmar

Avatar

Avatar

alcdtrainer1

Avatar

alcdtrainer1

alcdtrainer1

26-06-2015

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

if(this.rawValue !=  nul)

     this.access = "protected";

Thanks

Avatar

Avatar

jasotastic81

Avatar

jasotastic81

jasotastic81

25-06-2015

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.