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 Platform Community / Forums / Power Apps / Using SharePoint Power...
Power Apps
Unanswered

Using SharePoint Power app, How to add custom validation on List Form

(0) ShareShare
ReportReport
Posted on by

In SharePoint Online, I have created a simple power app on a custom List. I want to add a validation on Title Column (Start with "Project -") on Form Submission. That is, user should not be able to submit the Form if Title column value doesn't start with "Project -". User should see an error and then they should modify the Title value and save again.

 

I found Validate function in PowerApps link but unable to understand how to apply this to the form for my custom validation.

Please let me know how to add custom validations on list fields in Power App Form?

 

Thanks in advance

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    on at

    Hi @Vivek,

     

    There are several ways to implement that. Take a look at the following example:

    Create a EditForm:
    10.png

     

    When you connect to the SharePoint list and add the fields they create 4 controls in the data card:
    DataCardKey for the label, DataCardValue for the input, ErrorMessage for displaying error messages, StarVisible for * icon if it is required. 
    11.png

    You can use the ErrorMessage control to display your custom error.

    First unlock the datacard so that you can edit its properties
    12.png

     

    Now in the ErrorMessage under its Text property enter a function like this:

    If(Left(DataCardValue3.Text,9) = "Project -","","Project must start with Project -")

    It will check if left 9 characters are equal to Project - if they are then no error messages if they are not then error message.

    You have to also put a function on the Submit button to not submit if the string does not contain Project -.
    Under button OnSelect property put the following function:

    If(Left(DataCardValue3.Text, 9) = "Project -",SubmitForm(Form1))


     This will allow to submit only if the user input contains Project - at the start.

    However this will always display the error message even before the user starts to enter an input. If you want to display an error message only after the user clicks the Submit button replace the ErrorMessage Text function to the following:

    If(Left(DataCardValue3.Text,9) = "Project -","",ErrorMessageVariable)

    13.png

     

    And the Submit button OnSelect function to:

    If(Left(DataCardValue3.Text, 9) = "Project -",SubmitForm(Form1),UpdateContext({ErrorMessageVariable:"Project Name has to start with Project -"}))

    14.png

     

    This way the error message will be only displayed after user entered the input and clicked submit, the form will not submit if it does not contain Project - and will display the error next to the field.

    When you launch the app and enter some random text:
    15.png

     

    After clicking the button, the form will not be submited but the error message will display:
    16.png

     

    Hope it helps!

     

  • v-micsh-msft Profile Picture
    on at

    Hi @Vivek,

     

    We could write formula to check the Title field, if the Text Inputed is not start with "Project-", show the error message and have the Save Button disabled.

    Formula and the corresponding property should be set:

    1. For save Button, change its Disabled property with the formula below (DatacardValue8 is the textinput box for the Title field):

    If(
     StartsWith(DataCardValue8.Text,"Project-"),
     false,
     true)

    2. UnLock the Title field DataCard through Advanced tab under the right pane, then insert a Label control, put it besides the Ttile DataCard key, configuring the following property:

    Text property:  "Please start with 'Project-'"

    Color property: RGBA(255,41,43,1)

    Visible Property: If(StartsWith(DataCardValue8.Text,"Project-"),false,true)

    Doing it in this way would remind the user to enter the Title to stat with "Project-", if not, the Label with the red remindings would not be hidden, and the Save Button would be disabled.

    Only when the Text is start with "Project-', remindings would be hidden, and the save button would become available.

    88.PNG89.PNG

    Function reference:

    StartsWith function in PowerApps

    For Validate function, it uses the restriction from the data source side, if you have configured the restriction from the SharePoint side (For the title field to start with "Project-"), then this function should be OK to replace Startswith function.

     

    Regards,

    Michael

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