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 / 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:
I have the same question (0)
  • 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

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard