Get display state from attachment control by CSS


Badge +1

I am building a custom validation in Custom Javascript on a Nintex form and want to include a logical condition (if attachement control is not hidden) before checking if there are files attached using the 

GetNumberOfAttachments function.
 
Nintex JS will have to:
1. if attachement control is hidden then 'control is valid
2. if attachement control is visible and file(s) are attached 'control is valid
3. if attachement control is visible and no files(s) are attached ' control is invalid
 
The # of files uploaded is already working. Only difficulty so far, and solution I am looking for is to determine if the control is hidden or not.
Since the control has no Client ID storage I have to deal with the CSS class. But I cannot find any attribute which defines the current state of the attachement control. 
 
When trying NWF$('.nf-css-att-1-1').css('visibility') or NWF$('.nf-css-att-1-1').css('display') both will result in a visible (block) state.

 

can anyone help me making this work?


3 replies

Badge +10

what is the value that makes the attachment control hidden? check on that value and the number of attachments to validate.

Badge +1

Hi sojanm

 

Thank you for your fast reply.
The controls are hidden by rules. There are multiple rules controlling the display of about 10 attachement controls.

But I have discovered what happened. My fault and a stupid one.
Was including a few css class driven test alerts to see what value was returned and by coincedence I selected all non-hidden controls. So first I was wondering why it returned all display:= block and visibility:= visible because I was so sure to have a mixed state of controls included what apperently ws not the case.

I used now to test:

alert(''+NWF$('.nf-css-att-5-1').css('display')+'');  result: block
alert(''+NWF$('.nf-css-att-5-2').css('display')+'');  result: none
alert(''+NWF$('.nf-css-att-5-3').css('display')+'');  result: none


I used the following script (part):

if(NWF$('.nf-css-att-5-1').css('display') == 'none'){ alert('valid'); validFields.push(NWF$('.nf-css-att-1-1')); } else { if(!GetNumberOfAttachments("nf-css-att-1-1") > 0) { alert('checked invalid'); validated = false; invalidFields.push(NWF$('.nf-css-att-1-1')); } else { alert('checked valid'); validFields.push(NWF$('.nf-css-att-1-1')); }}
.... and so on for all other att-controls.

Thank you for your help and believe it or not. Your answer probably helped me identifying that.



Badge +10
It is all your hard work

Reply