Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Need field to be read only once saved...

Avatar

Level 4

I have altered the current date field to create a unique ID for a form. What I need it to do is to become READ ONLY once the user clicks the Submit button. Below is my current FormCalc code

$.rawValue = Concat(Num2Date(Date(), "MMDDYY"), "-", Num2Time(Time(), "hMMSS"))

Any ideas? THanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

put it into an if expression.

if ($.isNull) then

     $ = Concat(Num2Date(Date(), "MMDDYY"), "-", Num2Time(Time(), "hMMSS"))

else

     $.access = "readOnly"

endif

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

Hi,

put it into an if expression.

if ($.isNull) then

     $ = Concat(Num2Date(Date(), "MMDDYY"), "-", Num2Time(Time(), "hMMSS"))

else

     $.access = "readOnly"

endif

Avatar

Level 4

As a followup, how would I make a plain text field become read only once a value is entered and the field is exited?

Avatar

Level 10

It's solution is similar.

Add this script to thr fields exit event.

if (not $.isNull) then

     $.access = "readOnly"

endif

Avatar

Level 4

Is there a way to make it so that when the submit button is clicked it makes all form fields read only? Thanks!

Avatar

Level 10

Hi,

you can use a recursive loop to find all field objects in your form.

Here's an example.

function lockFields(vNode) {

    if (vNode.className == "field") {

        vNode.access = "readOnly";

    }

    for (var i = 0; i < vNode.nodes.length; i += 1) {

        lockFields(vNode.nodes.item(i));

    }

}

 

lockFields(xfa.form);