Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Unanswered

Validation that a file column has a file upload only when one or more yes/no fields = yes

(0) ShareShare
ReportReport
Posted on by 5

full disclosure, I am a newbie, I don't know what I don't know. 

I'm using validators reasonably successfully in this page and others, but I cannot figure this one out.

There are 5 yes/no fields on my page and a hidden file column field.
if any of fields 1-4 is "yes", the file field is revealed. 

I would to add a validator that checks that there is a file entered in the field, but only if any of fields 1-4 is yes.

I have everything up to the evaluation function, and the "check fields" portion of the evaluation function is straightforward (the same as the working hide/show logic - ugly but functional 😉) but I cannot fathom how to check that there is a file uploaded. 

If anyone could help me with that logical test, I would be truly grateful! 

I've cannibalised the built-in evaluation function used when making the file column required in studio  ValidatorTrim(ValidatorGetValue(val.controltovalidate)) != ValidatorTrim(val.initialvalue)
but no joy. There doesn't seem to be much out there in google or chatGPT that understands file column - all the suggestions have been to check the length of the first element of files and my understanding is that a file column is a single binary object?

What method or technique do I use to check that the file column is not empty???
TYVM in advance!

Categories:
  • oliver.rodrigues Profile Picture
    9,319 Most Valuable Professional on at
    Re: Validation that a file column has a file upload only when one or more yes/no fields = yes

    You can use 

    $("#<your file column>_input_file").val();

    if that is empty it's missing the file 

  • PatJazzy Profile Picture
    5 on at
    Re: Validation that a file column has a file upload only when one or more yes/no fields = yes

    Thank you. I was thinking along those lines, but it was specifically "check if file has data" that I was having trouble with. I couldn't figure out how to establish if a file column has data in it.

    In the end, I used this as part of the logical test that worked - or rather, didn't fail!
     document.querySelector("#my_field_file_name").textContent.length == 0

     

    I can't testify to the elegance of the statement but it got me out of a hole 😁

  • oliver.rodrigues Profile Picture
    9,319 Most Valuable Professional on at
    Re: Validation that a file column has a file upload only when one or more yes/no fields = yes

    Hi

     

    my implementation here would be something like:

     

    • Add on.change event handlers to Yes/No fields (it seems you have that working fine)
    • Add validation to the page with the Evaluation Function being something like:
      • if (choice1 == YES || choice2 == YES || choice3 == YES || choice4 == YES)
        • check if file contains data

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 69 Super User 2025 Season 1

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 49 Most Valuable Professional

#3
Jon Unzueta Profile Picture

Jon Unzueta 43

Featured topics