AnsweredAssumed Answered

Minimum attachment validation not working

Question asked by philipplucas on Jan 8, 2016
Latest reply on Jan 12, 2016 by philipplucas



i have following scenario: On my Nintex Form (2013) i have set a minimum of 1 attachment by directly editing the control settings. Additionally I have some JS code, that checks for special characters and for the length of the filename.


I put the JS code directly in the Form settings "Custom JavaScript" area. This is the JS:


function ValidateAttachments() {
 var isValid = true;
 var maxFileNameLength = 100;
 NWF$('.nf-attachmentsTable').find('tbody').find('tr').each(function() {
  var file = NWF$(this);
  var fileName = file.find('span')[0].innerText;
  var match = (new RegExp('[~#%\&{}+\|]|\\.\\.|^\\.|\\.$')).test(fileName);
  if (match) {
   isValid = false;
   alert('invalid file name: ' + fileName + '; no special characters allowed');
  } else if (fileName.length > maxFileNameLength){
    isValid = false;
    alert('too long file name: ' + fileName + '; only 100 characters allowed ');
 return isValid;


The function is called when the save button is clicked. I added the function as Client Click event in the "Advanced" tab of the control settings of the save button ("return ValidateAttachments()")


Funny thing is, both checks are working fine for themselves. But after I implement the JS method, the standard validation of the attachment control, checking for the minimum number of 1 attachment, won't work anymore. Which means as soon as i implement the JS method and let it execute by clicking the save button, I can check for special characters and the length of the filename but i can also just save the form without addind any attachment at all, although the control validation still says minimum of 1 attachment.


Can someone explain me why this is happening and what i need to do to get both checks applied? Of course i could try to add the "minimum numer of attachments"-check in the JS code as well, but I need to understand why my code is deactivating the standard validation.


Hopefully someone can enlighten me.


Thanks in advance