Power Apps | Formulae exercise | Create a form with validation applied to its text boxes

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

You can learn how to do this exercise if you attend the course listed below!

Software ==> Power Apps  (13 exercises)
Version ==> Latest update
Topic ==> Formulae  (2 exercises)
Level ==> Average difficulty
Course ==> Power Apps

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a new mobile or tablet app, and save this as Postcode Lottery.

Add labels and text boxes to get something like this:

Postcode application form

You can use the HintText properties of the text boxes to show the prompts.

 

Disable the Enter button if either or both of the two text boxes are not filled in (set a formula for the button's DisplayMode property to do this).  You can test whether a text box is filled in by seeing whether the length of its text is more than 0 characters - for example:

If( ... Len(Trim(txtName.Text)) > 0 ...

If this is working, it's time to be more ambitious.  Add a postcode error message label which only remains visible while the postcode entered is invalid:

Error label

Set the Visible property of the error message label to an expression, using the hint below.

 

Don't be too fussy about the postcode (the rules are quite complicated) - just use the IsMatch function to ensure that it starts with any series of characters then has a space, a number and two letters:

MultipleNonSpaces & Space & Digit & Letter & Letter 

Attach an action to the Enter button so that it awards a prize 50% of the time (you can use the Rand() function to return a random number between 0 and 1, and test whether this is less than 0.5 or not).  So you'll alternate between these two messages:

Losing message Winning message
Glass half-empty ... ... or half-full

To reclaim your prize from Wise Owl, please send us your bank details so that we can deduct a small processing fee before remitting your million pound prize.

Test your app, save it and close it down!

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post