• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using JS to form check, unhide signature field

Community Beginner ,
Nov 14, 2024 Nov 14, 2024

Copy link to clipboard

Copied

Hello community!! I have checked the forum and have gotten some decent ideas about what Im trying to do here but Im hung up a bit. I need to create a button that will check 3-4 textfields and 2-3 sets of checkboxes. If any of the items in question are blank/not selected, alerts will be thrown to the user, notifying them that they need to complete these items prior to the signature field unlocking. I currently have logic that I have in a textfield that will do this and then clear itself but I need to transpose this to a button and ensure that the signature field in question does not become visible unless the user has the required fields filled out/checked. This is the logic I have for the text field: 

 

var sectionThree = ["checkbox1", "checkbox2"];
var sectionFive = ["checkbox3", "checkbox4", "checkbox5", "checkbox6", "checkbox7", "checkbox8"];
var sectionSix = ["checkbox9", "checkbox10", "checkbox11", "checkbox12", "checkbox13", "checkbox14", "checkbox15", "checkbox16", "checkbox17", "checkbox18", "checkbox19", "checkbox20", "checkbox21", "checkbox22", "checkbox23", "checkbox24", "checkbox25"];

function checkSections() {
var oneYearFromDate = this.getField("oneYearFromDate").value;
var orgName = this.getField("organizationIndividualName").value;
var orgRelationship = this.getField("organizationIndividualRelationship").value;
var pastDates = this.getField("pastDates").value;
if (staffSignature !== "") {
var sectionThreeChecked = false;
var sectionFiveChecked = false;
var sectionSixChecked = false;

for (var i = 0; i < sectionThree.length; i++) {
if (this.getField(sectionThree[i]).value !== "Off") {
sectionThreeChecked = true;
break;
}
}

for (var i = 0; i < sectionFive.length; i++) {
if (this.getField(sectionFive[i]).value !== "Off") {
sectionFiveChecked = true;
break;
}
}

for (var i = 0; i < sectionSix.length; i++) {
if (this.getField(sectionSix[i]).value !== "Off") {
sectionSixChecked = true;
break;
}
}

if (!sectionThreeChecked) {
app.alert("Please make sure you have selected at least one checkbox from Section 3: Authorization", 1);
event.value = "";
}
if (orgName == "") {
app.alert("Please make sure you have completed Section 4: Organization/Individual Name.", 1);
event.value = "";
}
if (orgRelationship == "") {
app.alert("Please make sure you have completed Section 4: Relationship.", 1);
event.value = "";
}
if (!sectionFiveChecked) {
app.alert("Please make sure you have selected at least one checkbox from Section 5: Information Purpose", 1);
event.value = "";
}
if (!sectionSixChecked) {
app.alert("Please make sure you have selected at least one checkbox from Section 6: Information Requested/Released.", 1);
event.value = "";
}
if (pastDates == "") {
app.alert("Please make sure you have completed Section 7: Past Dates, use N/A if not applicable.", 1);
event.value = "";
}
}
}

this.getField("oneYearFromDate").calculate = checkSections();

 

Obviously I need to modify this and place it in the action menu of the button Im guessing but what is the best action to use? MouseUp? Any help with this is much app[reciated, thanks in advance!!!!

TOPICS
Edit and convert PDFs , JavaScript , Modern Acrobat , PDF , PDF forms

Views

118

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2024 Nov 14, 2024

Copy link to clipboard

Copied

Mouse up for a button field.  What trigger are you using for the current script in the text field?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 14, 2024 Nov 14, 2024

Copy link to clipboard

Copied

Right now its embedded as a custom calculation script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2024 Nov 14, 2024

Copy link to clipboard

Copied

LATEST

So every time a field value changes the user will get all those alerts if any sections are missing a check box?  Definitely a mouse up action in a button.  Your last line doesn't make sense.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2024 Nov 14, 2024

Copy link to clipboard

Copied

What is this line supposed to do? :

this.getField("oneYearFromDate").calculate = checkSections();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines