Copy link to clipboard
Copied
Hello,
I have a form with multiple check boxes. Some of the check boxes have a text field that is required to be filled in if the box is checked off. How can I make sure that the field is filled in if the box is checked? Right now, I checked off "required" in the common functions under General. But it's not making them fill in the box.
Copy link to clipboard
Copied
The automatic processing of the "required" property only works for submission to web page or email service. Any other action will require you to write a custom JavaScript action to detect the fields not completed and report the issue to the user.
Copy link to clipboard
Copied
Thank you. Can you help me with the code? I have Checkbox1 and Text1
On Saturday, March 23, 2019, 7:22:53 PM EDT, gkaiseril <forums_noreply@adobe.com> wrote:
Required field after it is checked created by gkaiseril in PDF Forms - View the full discussion The automatic processing of the "required" property only works for submission to web page or email service. Any other action will require you to write a custom JavaScript action to detect the fields not completed and report the issue to the user.
If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10993414#10993414 and clicking ‘Correct’ below the answer
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10993414#10993414
To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
Start a new discussion in PDF Forms by email or at Adobe Community
For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.
This email was sent by Adobe Community because you are a registered user. You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences |
Copy link to clipboard
Copied
Hello,
I have not received a reply. How would the code read? I have Checkbox1 and Text1? When checkbox1 is checked, I would like the user to get a notification that text1 needs to be filled in before completing the rest of the form, including if they attempt to print and/or save the form and i would like the form to stop working until text1 is filled in.
Copy link to clipboard
Copied
This is the method I teach:
Put this code in the Checkbox on the Mose Up Event.
Replace "R1" with the checkbox, or name the button R1
Replace "R2" with the name of the field, or name the button R2
Note if you have another language version of acrobat confirm that the Options: Export Value is "Yes" if the checkbox is checked. Either you change the value to "Yes" or you replace the code in the sample.
var myBox = this.getField("R1");
var myField = this.getField("R2");
if (myBox.value === "Yes") {
myField.required = true;
}
if (myBox.value !== "Yes") {
myField.required = false;
}
Copy link to clipboard
Copied
Sorry but I entered the incorrect information in my request. I have radio buttons that are mutually exclusive. Will that make a difference? I tried to copy and paste the Java but it does not work.
Copy link to clipboard
Copied
The language being used in Acrobat PDF forms is JavaScript, not the compiled Java language.
It is not a good idea to just cut and paste code since JavaScript uses the basic 128 ASCII character set.
Have you opened the JavaScript console to see if there are any reported errors?
The field with focus should be accessed using the event object and not the file object.
If you have multiple check boxes or radio buttons, then you. need to provide the code for each button in the exclusionary group.
Radio buttons and check boxes are very similar except that a check box can be unchecked by clicking on it a second time. Once a radio button has been selected it cannot be changed except by checking another radio button in the group or using JavaScript code to rest the field or group.
Since a comparison to the desired value of the check box or radio button will either be true or false as will be the required property, one can set the required property based on the result of the comparison to the value of the check box or radio button. The script can be:
this.getField("Text1").required = (this.getField(event.target.name).value == "Yes");
By using the event target's name, one does not need to code in the check box's or radio button's name. That means the only value changing in the name of text field whose required property is being changed to the result of the comparison.
The JavaScript console can be opened with the <Ctrl> + "J" key combination or in the "Prepare Form" tool under "More".
JavaScript is case sensitive and if a field has null value, then that field cannot be found.