This blog post delves into the intricacies of data verification for Power Apps forms. By exploring validations for text fields, date pickers, and dropdowns, readers are equipped with practical code snippets to ensure data integrity and user feedback. Additionally, it provides a visual guide on error indications, enhancing user experience.
If(IsBlank(DataCardValue1.Text),Color.DarkRed, Parent.BorderColor)
Here is the result of this !
Whenever the text field is blank the border color and hover border color remain red
And when the user enters any data in the text field the color of the border and hover changes to the parent
Click on the date picker control inside the data card.
Under the “OnSelect” or “OnChange” property, you can add a formula to ensure the date is within a certain range
Use this code:
If(DateValue4.SelectedDate > Today(), Notify("The date cannot be in the future", NotificationType.Error))
When the user selects the passed date it will show an error notification
Click on the dropdown control inside the data card
Under the “OnChange” property, you can add a formula to ensure a valid option is selected:
Use this code
If(Dropdown1.Selected.Value ="Started", Notify("You have selected a valid option",NotificationType.Success),Notify("You have selected a valid option",NotificationType.Error))
It will show an error massage if selected option from dropdown is not “started”
It will show success massge if selected option from dropdown is “Started”
Now we USE cancel icon and CHECK icon adjust them Infront of our each DataCard
We use them to show error when a wrong data entered
We use this code in icon property of icon
If(IsBlank(DataCardValue1.Text),Icon.Cancel, Icon.Check )
And use this code for fill color
If(Self.Icon=Icon.Cancel, Color.DarkRed ,Color.DarkGreen)
Or when any data field is blank
These icon’s are visible any of text field is blank and or
Passed date is selected in date picker
When each field is filled with correct data icon checks are visible
Now validate phone number and email address formats
We use this code on the icon property of the icon
If( IsMatch(DataCardValue1_2.Text,Match.Email), Icon.Check,Icon.Cancel)
Here ‘@’ is missing so its showing error
Now add the missing sign ‘@’
Now phone number validation
We use this code for phone number validation
Icon property of icon
If(
IsMatch(
DataCardValue1_1.Text,
Match.Digit&Match.Digit&Match.Digit&"-"&
Match.Digit&Match.Digit&Match.Digit&"-"&
Match.Digit&Match.Digit&Match.Digit&Match.Digit
),Icon.Check,Icon.Cancel)
Here is the result when we enter wrong format phone
When we enters correct formate
Ensuring data integrity in Power Apps forms is vital for any application. Through strategic use of code and visual cues, users can now seamlessly understand and rectify their input errors, leading to improved data accuracy and enhanced user experience.
Copyright © 2022 Software Zone 365 All Rights Reserved.
Discover customized solutions with our PowerApps experts. Whether you're building apps, automating workflows, or integrating services, we're here to ensure your projects succeed.
🎁 Get a Free 30-Minute Support Consultation!
✅ Book Your Free Session Now