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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Form Validation

(0) ShareShare
ReportReport
Posted on by 454 Super User 2024 Season 1

Hello Power Apps Community,

 

I am seeking an easy way to disable a form's save button if any of the required fields on the form are not completed, or any field on the form (even non-required fields) fails validation.

 

Originially, I was using the following code in the form's DisplayMode property:

 

If(
!IsBlank(ErrorMessage69.Text) || !IsBlank(ErrorMessage70.Text) || !IsBlank(ErrorMessage71.Text) ...
DisplayMode.Disabled,
DisplayMode.Edit
)

However, this means I have to list every field on the form.

 

I would prefer to use something like the following code:

 

If(frmRecord.Valid,DisplayMode.Edit,DisplayMode.Disabled)

 

However, this only disables the save button in my app if a required field is not completed on a form.

 

Is there a way to get the ".valid" property to show True for fields that don't fail validation (i.e. show an error message)? Thus I could use "FormName.Valid" in the Save button's DisplayMode to disable it if required fields are not completed AND any field shows an error message because it fails data validation. 

 

Thanks for reading,

Matren

 

CC: @WarrenBelz , @RandyHayes 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Matren 

    Yes, the key here is to have all the fields that require some value and those that require some validation to have the Required property of the data card set to true.

     

    For the fields that require validation, just alter the Update property of the datacard to provide blank if it fails validation (thus that card will not have a value and since it is listed as Required, the form.Valid will be false).

     

    For example, if you are trying to do email validation on a textinput, then the Update would be:

    If(IsMatch(yourTextInput.Text, Email), yourTextInput.Text, Blank())

     

    Now your form.Valid will reflect both required values and validation as well.

     

    I hope this is helpful for you.

  • Verified answer
    Matren Profile Picture
    454 Super User 2024 Season 1 on at

    Hi @RandyHayes,

     

    Thank you for your quick response. Your recommendation led me to the right solution for my app.

     

    Since I was leveraging the Error Message to store the data validation for the DataCard, here was my final configuration:

     

    SaveButton.DisplayMode - If(FormName.Valid,DisplayMode.Edit,DisplayMode.Disabled)
    ---------------
    ErrorMessage - Place data validation criteria here (mine was long)
    DataCard.Required - !IsBlank(ErrorMessage) - If error message is showing as a result of data validation failing, then the DataCard is required
    DataCard.Update - If(IsBlank(ErrorMessage.Text), DataCardValue.Text, Blank()) - DataCard.Update will show blank (causing the save button to be disabled) when there is an error message as a result of the data validation criteria failing.
    StarVisible - I left it at "*" and so it will show the asterisk when it fails data validation. This is a matter of preference.

     

    I appreciate any further comments you or others deem necessary.

     

    Thanks,
    Matren

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard