Lock a specific Text Field

Avatar

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
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
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
Boost 1
Level 2
alcdtrainer1
Level 2

Likes

2 likes

Total Posts

31 posts

Correct reply

6 solutions
Top badges earned
Boost 1
Applaud 5
Applaud 25
Affirm 5
Affirm 3
View profile

Avatar
Boost 1
Level 2
alcdtrainer1
Level 2

Likes

2 likes

Total Posts

31 posts

Correct reply

6 solutions
Top badges earned
Boost 1
Applaud 5
Applaud 25
Affirm 5
Affirm 3
View profile
alcdtrainer1
Level 2

07-07-2015

Thanks Radzmar

Avatar

Avatar
Boost 1
Level 2
alcdtrainer1
Level 2

Likes

2 likes

Total Posts

31 posts

Correct reply

6 solutions
Top badges earned
Boost 1
Applaud 5
Applaud 25
Affirm 5
Affirm 3
View profile

Avatar
Boost 1
Level 2
alcdtrainer1
Level 2

Likes

2 likes

Total Posts

31 posts

Correct reply

6 solutions
Top badges earned
Boost 1
Applaud 5
Applaud 25
Affirm 5
Affirm 3
View profile
alcdtrainer1
Level 2

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
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

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.