You create a canvas app.
On the first screen of the app, you put a Text input field (TextInput1) and a “Submit” button (Button1)
You want to enable the “Submit” button when a user types a valid email address.
Here is your formula:
If(IsMatch(TextInput1.Text, Email), Edit,Disabled).Where should you put this code?
Click on the arrows to vote for the correct answer
A. B. C. D. E.Correct Answer: E
Formulas in Power Apps are similar to Excel.
But in Power Apps, formulas perform operations on the app and app's controls instead of cells and spreadsheets.
For formulas operations, you can use various elements like: Functions - operate on the parameters and return values.
There are specific Power Apps group of functions - behavior functions.
This group describes the behavior of the controls like the Button when you push it.
Signals - provide information about an environment like GPS coordinates.
Enumerations - return predefined constant values like Color with the set of its properties: Color.Red, Color.Blue, etc.
Named operations - return a reference to the app or app's controls like Self, Parent, ThisItem, or ThisRecord.
Controls and their properties - operate on the properties for setting control's configuration.
There is a list of controls that you can use in your apps like Button, Check Box, Column chart, etc.
When you need to change the controls state (Enabled/Disabled) on a canvas screen, you put code in the DisplayMode.
There are three states for the DisplayMode: Edit, Disabled, and View.
By default, the control's DisplayMode is set to Edit.
When the DisplayMode is set to View, the control looks like in the Edit state, but a user cannot select it.
All other options are incorrect.
For more information about managing canvas app controls by formulas, please visit the below URL:
The correct answer is E. Button1.DisplayMode.
Explanation: The formula provided is checking whether the text entered in the TextInput1 field is a valid email address or not using the IsMatch function. The IsMatch function takes two arguments: a string to match and a pattern to match against. In this case, the string to match is the Text property of TextInput1, and the pattern is the "Email" pattern, which is a pre-defined regular expression pattern for email validation.
The If function is used to conditionally set the DisplayMode property of the Button1. If the text entered in the TextInput1 matches the Email pattern, the formula sets the DisplayMode property of the Button1 to "Edit" (i.e., enable the button). Otherwise, it sets the DisplayMode property to "Disabled" (i.e., disable the button).
Therefore, to achieve the desired behavior of enabling the Submit button when a valid email address is entered, you should put this formula in the DisplayMode property of Button1. The other options (A, B, C, and D) are not relevant to this scenario.