Data validations in power apps

Loading

Data validations :-Power Apps Data validation checks whether the value of a single column or a complete record is valid for a data source. Data Validation within apps and business forms is critical to prevent errors, and to ensure data transactions occur without errors and uncomfortable bottlenecks during submission.

To implement data validation in Power Apps, we need to first unlock the Data card value and then rename the fields that you want.
To unlock the Data Card, select one data card -> go to Advanced tab -> Click on the Lock icon.

Regular expressions can be used in Power Apps to achieve text input validation,  Power Apps provides three types of functions for text validation: Is match, Match and Match all

Is Match – This function gives you a Boolean (true/false) answer of whether or not some string of text matches a certain pattern.
Match – Let’s you know what in the string of text matches a certain pattern, such as finding an email address somewhere in a text box and letting you know what the email address is.
Match All – Let’s you know all matches of a certain string or pattern with

To showcase Power Apps data validation examples, we will create a Power Apps app from a SharePoint Online list and then we will implement the validations.  

Step 1: In the Modern SharePoint Online Site, Create a SharePoint List as “Empinfo”.  We will work on a SharePoint list with below columns: 

Title :-Required field Asterisks mark (*)

Name:-Required field Asterisks mark (*)

Age:-Must be more than 25

Department:-

Empid:-

EmpEmail:- Must be in the formate

phone number:-Must be in the formate

Step 2: Create an app for the above created SharePoint List.  

  • Go to Power Apps tab  
  • Click on Create an app as shown below.

Step 3: Provide a name for the new app to get Started and Press on Create Button

Now we will be implementing data validation in above newly created app. 

Implement required field validation in Power Apps :- 

Step 1: Select the card

Step 2: From the advanced properties choose to unlock to change properties 

Step 3: On the Required property of the card change it to be true 

In the below screenshot, you can see there will be an Asterisks mark (*) in the Specialist field. This means that a specific field is mandatory to fill by the user. 

Title field Validation :-

Step 1:  Select the Doctor Name field Data Card and unlock it. 

Step 2:  Insert an Icon in the Doctor Name textbox. 

Step 3: Write below code in the Icon property of the Icon

if(isblank(Datacardvalue1.Text),icon.cancel,icon.check) 

Step 4: Write below code in the Icon property of the Color

Age field Validation :-

Step 1:  Select the Age field Data Card and unlock it. 

Step 2:  Insert an Icon in the Age textbox. 

Step 3:  Make the Format property to be number to allow only digits. 

Step 4:  Use the same method to create an Icon for ‘Age’ as was shown for ‘Title’ but change the logical expression in the Icon property to this instead. 

Step 5: Write below code in the Icon property

if(value(Datacardvalue3.Text)>=25,icon.chech,icon.cancel)

Step 6: Write below code in the Icon property of the Color.

if(self.icon=icon.chech,Green,Red)

Email field Validation :-

Step 1: Select the Email Address Field Data Card and unlock it 

Step 2: Insert an Icon in the Email Address textbox 

Step 3: There is a predefined matching pattern already exists for email addresses. Use this code in the Icon property of the icon for ‘Email Address’. 

Step 4: Write below code in the Icon property  

if(ismatch(Datacardvalue6.Text,Email),icon.check,icon.cancel)

Phone number validation :-

Step 1: Select the Phone number Field Data Card and unlock it.     

Step 2: Insert an Icon in the Phone number textbox. 

Step 3: Make the Format property to be number to allow only digits. 

Step 4: Write this code in the Icon property of the Icon. 

 

Step 5: Write this code in the Icon property of the Color.

 

Leave a Reply

Your email address will not be published. Required fields are marked *