Skip to main content
August 22, 2016
Answered

Javascript Radio Button app.alert

  • August 22, 2016
  • 1 reply
  • 1877 views

I have a pdf form that has required text fields and radio buttons. Once the user has filled out the form I've created a button that will check to see if all the required fields have been filled out, if yes then send an email, and then close the form without saving. If no, an app alert pops up and allows you to fill in the missing information. The app.alert works for the text fields but not the radio buttons. If the radio button is the only thing not filled out, I get the default error and then it skips the email portion and closes without saving the pdf. I have one set of radio buttons (qty of 3) called "group". Here is the JavaScript. Can someone please help.

var requiredFields = new Array();

for (var i = 0; i < this.numFields; i++)

{

var fName = this.getNthFieldName(i);

var f = this.getField(fName);

if (f.type!="button" && this.getField(fName).required && (this.getField(fName).value == null || this.getField(fName).value == ''))

{

requiredFields[requiredFields.length] = fName;}}

var error = "Please complete the following fields: \n\n";

for (j=0; j < requiredFields.length; j++)

{

if (requiredFields.value == null)

{

error = error + requiredFields + '\n';

var f2 = this.getField(requiredFields);

f2.setFocus();

}

 

}

 

if (requiredFields.length > 0) {

app.alert(error);

} else {

this.submitForm ({

cURL:"mailto:none@none.com",

cSubmitAs: "PDF",

})

this.closeDoc(true);

}

This topic has been closed for replies.
Correct answer try67

The default value of a radio-button group when no button is selected is "Off", not null.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 22, 2016

The default value of a radio-button group when no button is selected is "Off", not null.

August 23, 2016

I changed both nulls to off and it doesn't work as well as changing each one separately and it didn't work. I guess I don't understand what I'm suppose to change.

try67
Community Expert
Community Expert
August 23, 2016

It's not "off" but "Off". JS is case-sensitive.