Is there a way to make an entire form read only if a certain text field is filled in? I know that adding a digital signature field to a form, increases the size of the form, so I would prefer not to add a digital signature field to my form. However, I would like the feature that says after the form is signed, it is read only. I added a text box to the form and tried to add some script that read: if (this.rawValue != "") (this.access = "readOnly"), but that didn't work. Is there a way I can accomplish this without adding a signature field to the form?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
It depends on where you placed the script, probably best place is the exit event.
if (this.rawValue != null || this.rawValue != "")
{
this.access = "readOnly";
}
else
{
this.access = "open";
}
This will only lock the field that the script is inside.
You should check out Paul's example LockAllFields, which contains a function in a script object. While Paul calls this from a click event in a button, you could call it fromthe exit event of the particular text field.
Re: Saving Fillable Form as non-fillable PDF
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
It depends on where you placed the script, probably best place is the exit event.
if (this.rawValue != null || this.rawValue != "")
{
this.access = "readOnly";
}
else
{
this.access = "open";
}
This will only lock the field that the script is inside.
You should check out Paul's example LockAllFields, which contains a function in a script object. While Paul calls this from a click event in a button, you could call it fromthe exit event of the particular text field.
Re: Saving Fillable Form as non-fillable PDF
Hope that helps,
Niall
Views
Replies
Total Likes
That does lock the form. However, I just realized, it locks the form whether a name has been entered in the field or not. Can I make it conditional somehow (so that it will only lock the form if a name has been entered)?
Views
Replies
Total Likes
Hi,
If you are using Paul's button and the function in the script editor as is, then you it will lock all fields on click.
In the click event of the button, you could wrap the call to the function in an if statement.
if (myTextField.rawValue != null || myTextField.rawValue != "")
{
myScriptObject.LockAllFields(form1);
}
The button won't do anything unless the text field has a value.
Hope that helps,
Niall
Views
Replies
Total Likes
I am using Paul's function. However, I am trying to put it on the exit event of my text field. I tried wrapping it in the if statement you provided. However, when I test the form, by clicking in the text field and then clicking off of it without adding any text, the form is still locked. Will this function not work properly on a text field?
Views
Replies
Total Likes
Hi,
It will work under any event, as the script is just calling the function.
Just make sure the script is in the exit event and not in the click event of the textfield. User input only gets committed to the textfield's rawValue on exiting the field.
Try a different approach for the test:
if (!(myTextField.rawValue.isNull))
{
myScriptObject.LockAllFields(form1);
}
Remember: javascript in the exit event.
Hope that helps,
Niall
That's perfect. Thank you very much for all your help!
Views
Replies
Total Likes
Is there a way for this code to lock all the fields in the form except two? The form I am working on needs to be countersigned, so I would like the Company Signature field and the Company Signed Date field to remain unlocked, while the rest of the form is locked.
Views
Replies
Total Likes
The easiest way is to simply allow all the fields to lock and unlock then after function completes. Something like this:
myScriptObject.LockAllFields(form1)
FieldName1.access ="open"
FieldName2.access = "open"
But that is not a very efficient use of code. If you want to be more correct then you shoudl modify the function to check for the name of your two fields and leave them out of the locking mechanism. If you are not technical then do not attempt this simply do it like I did above.
Paul
Views
Replies
Total Likes
That works perfectly. Thank you very much for your assistance.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies