web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom Form: Setting V...
Power Apps
Suggested Answer

Custom Form: Setting Validation Conditions

(0) ShareShare
ReportReport
Posted on by
I need help with the validation of a form before the user can click submit. This is form is specifically for amending an item in a SharePoint library. The columns are Topic Title, Presenter, Date, File Name.
 
If the user wants to amend something, they must first select a topic from the dropdown (populated from SharePoint). Once a topic is selected (varSelectedTopic), four checkboxes appear (CheckPresenter, CheckDate, CheckUploadNew, and CheckUploadReplace). The user must select at least one of these checkboxes.
 
Upon selecting any checkbox, an associated input field appears (NewPresName - text input, NewDate - Date Picker, FileAtts_1 - Attachment). For any selected checkbox, its associated input field must contain an input for the form to be valid.
 
I am using the following code on a hidden button (ValButton), and using Select(ValButton) in the OnSelect properties of each checkbox, OnChange property of text and date inputs, and OnAddFile property of Attachment.
 
The process works fine until the first checkbox selection and text entry. After that if I check CheckDate the form stays valid. If I then uncheck date without entering any input, the form turns invalid. I have tried nested if (below) and a boolean based approach, but to no avail. Can anyone point out what I am doing wrong?
 
// Nested Ifs
If
(
    // 0) Topic must be selected
    IsBlank(varSelectedTopic),      // Topic selection blank?
    Set(varSubmitValid, false),     // Yes - Invalid
                                    // No - Check the checkboxes
    // 1) At least one action must be selected 
    If(
        !(CheckPresenter.Checked || CheckDate.Checked || CheckUploadNew.Checked || CheckUploadReplace.Checked),     // Are all boxes unselected?
        Set(varSubmitValid, false),                                                                                 // Yes - Invalid
                                                                                                                    // No - Check corresponding inputs
        // 2) If Presenter change is selected → require non-blank name
        If(
            CheckPresenter.Checked && IsBlank(Trim(NewPresName.Value)),
            Set(varSubmitValid, false),
            // 3) If Date change is selected → require a date
            If(
                CheckDate.Checked && IsBlank(NewDateInput.SelectedDate),
                Set(varSubmitValid, false),
                // 4) If Upload New → require exactly one attachment
                If(
                    CheckUploadNew.Checked && CountRows(FileAtts_1.Attachments) <> 1,
                    Set(varSubmitValid, false),
                    // 5) If Replace Existing → require a target + exactly one attachment
                    If(
                        CheckUploadReplace.Checked && (
                            !varHasReplaceableFiles
                            || IsBlank(varFileReplaceDrop)
                            || CountRows(FileAtts_1.Attachments) <> 1
                        ),
                        Set(varSubmitValid, false),
                        // All checks passed
                        Set(varSubmitValid, true)
                    )
                )
            )
        )
    )
);
 
//Boolean Based
Set(
    varSubmitValid,
    !IsBlank(varSelectedTopic)
    &&
    (CheckPresenter.Checked || CheckDate.Checked || CheckUploadNew.Checked || CheckUploadReplace.Checked)
    &&
    If(CheckPresenter.Checked, !IsBlank(Trim(NewPresName.Value)), true)
    &&
    If(CheckDate.Checked, !IsBlank(NewDateInput.SelectedDate), true)
    &&
    If(CheckUploadNew.Checked, CountRows(FileAtts_1.Attachments) = 1, true)
    &&
    If(CheckUploadReplace.Checked, varHasReplaceableFiles && !IsBlank(varFileReplaceDrop) && CountRows(FileAtts_1.Attachments) = 1, true)
);
Categories:
I have the same question (0)
  • Suggested answer
    Sam_Fawzi Profile Picture
    917 Super User 2026 Season 1 on at
     
    try to Set your Submit button DisplayMode (or a label) to this formula:
     
    If(
        IsBlank(varSelectedTopic),
        Disabled,
        If(
            !(CheckPresenter.Value || CheckDate.Value || CheckUploadNew.Value || CheckUploadReplace.Value),
            Disabled,
            If(
                (CheckPresenter.Value && IsBlank(Trim(NewPresName.Text))) ||
                (CheckDate.Value && IsBlank(NewDateInput.SelectedDate)) ||
                (CheckUploadNew.Value && CountRows(FileAtts_1.Attachments) <> 1) ||
                (CheckUploadReplace.Value && (!varHasReplaceableFiles || IsBlank(varFileReplaceDrop) || CountRows(FileAtts_1.Attachments) <> 1)),
                Disabled,
                Edit
            )
        )
    )
    Notes (small but important):
    • Use TextInput.Text (not .Value)
    • Use Checkbox.Value (or .Checked, but be consistent)
    • Avoid Select(ValButton) entirely.
    This removes the race condition, so unchecking Date won’t “stick” as invalid unless another selected action is actually missing its input.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard