AnsweredAssumed Answered

JavaScript Attachment Validation for Radio Button

Question asked by tedwards on Feb 1, 2017
Latest reply on Feb 2, 2017 by emha

Hello, I have a form that has 2 attachments on it, the first was easy to configure that validation as it is mandatory for 1 attachment. The second attachment which is my default is only needed if user select Yes on a Radio Choice. I am having issues with code as I am new to javascript.

 

I have been following this post but cannot get it to work;

Attachment Validation based on checkbox in a Multiple attachment form 

Here is my choice control settings;

Here is the code that I have attempted with no luck;

 

function fnAttachmentValidation(source, arguments)
{
var Control = NWF$("#" + BankAttachmentID);
var elm = NWF$("table[id*=idAttachmentsTable]");
var elmAttachmentRow = NWF$("div[id*=idAttachmentsRow]");

if(Control.is(':checked') == true)
{ // minimum one attachment is required
if ((elm != null && elm.prop('rows').length > 0) && (elmAttachmentRow != null))
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
if(NWF$('.nf-validation-summary').css('display') !='non'){
WF$('.nf-attachment-control').css("border", "red solid 2px");
}
}
}

 

Can someone help me with the code, this is a mandatory requirement if user selects 'Yes' on the control, I cannot use the standard validation as if 'No' is selected I have a separate workflow that gets started.

 

Thank you,

Outcomes