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 / Validations in Canvas ...
Power Apps
Answered

Validations in Canvas APP imported from SharePoint List

(0) ShareShare
ReportReport
Posted on by 270

Hi,

I have a Canvas App, This APP is created from SharePoint List.

 

There are 11 fields that need to be required and 4 fields that require validation.

On clicking Submit button all these validations should be checked 

- the border color should change to red if mandatory field is empty

- the border color should change to red if the validation is not matching

- Throw an error label like  " The field is empty", "The Zip code pattern is not matching"

 

The following are the fields to be validated

 

Person Name (required field validation only )

Zip (mandatory field and requires validation) ,
Home Zip, SSN, DOB (non-mandatory and requires validation)

 

I am unsure of adding validation to the above fields.

The below code just changes the border color but doesnt show any error label. how do I configure , onsubmit every fields should be validated. only after proper validation, the form should be submitted.


zip*
If(IsMatch(DataCardValue5.Text,"^((\d{5}-\d{4})|(\d{5})|([A-Z]\d[A-Z]\s\d[A-Z]\d))$",MatchOptions.Complete), Black, Red)

 

home zip
If(
Not(IsBlank(DataCardValue48.Text)),
If(
IsMatch(DataCardValue48.Text,"^((\d{5}-\d{4})|(\d{5})|([A-Z]\d[A-Z]\s\d[A-Z]\d))$",MatchOptions.Complete),
Black,
Red
),
Black
)

 

ssn
If(
Not(IsBlank(DataCardValue50.Text)),
If(
IsMatch(DataCardValue50.Text,"^\d{3}-\d{2}-\d{4}$",MatchOptions.Complete),
Black,
Red
),
Black
)


dob:

 

If(DataCardValue49.SelectedDate < Today(),Black,Red)

 

Please help

 

 

Categories:
  • BCLS776 Profile Picture
    8,994 Moderator on at

    It looks like most of your conditions belong in a BorderColor property for the individual controls, or something similar. However, those conditions do not validate your data; they simply create a visual cue about a problem.

     

    To deal with data validation, I like to put condition(s) on the DisplayMode of the button used for submission. I keep it Disabled until the conditions I want are met, and then toggle it to Edit. This prevents a user from clicking the submit button and expecting something to happen.

  • JayashreeKrish Profile Picture
    270 on at

    @BCLS776  Thanks much.. Can u please post a sample code to be written in Submit button for two fields? There is issue while nesting conditions

  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    This code goes in the DisplayMode property of a button to disable/enable the button:

    If(DatePicker1.SelectedDate > Today(),DisplayMode.Disabled, DisplayMode.Edit)

    You can build a condition on variables, control values, and other logical expressions to manipulate this behavior. The OnSelect code of the button remains the same; we simply change the DisplayMode.

  • JayashreeKrish Profile Picture
    270 on at

    Thanks much

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard