cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rpoidoma1010
Level: Powered On

How do you make a field required?

I don't see a property to make a field required.  What is the best way to check if a field is populated when a user clicks a submit button on a form, and if not populated, highlight fields that need to be populated?  At the very least, I'd like to continue to show a message that required fields are not populated till all of them are.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mr-dang
Level 10

Re: How do you make a field required?

Each "card" of the form should have a Required property that you can set to true/false. The same property can be seen for each card in View>Advanced if you select the Form Gallery itself.

 

The templates provided by PowerApps typically use some form of this code for a Button.OnSelect:

 

If(!IsBlank(TextInput1.Text) &&
!IsBlank(TextInput2.Text) &&
!IsBlank(TextInput3.Text),

SubmitForm(form),

UpdateContext({ShowMessage: true}))

 

This means that if all of the text input fields are not blank, then the button will Submit the Form. Otherwise, it will change the ShowMessage variable to true.

 

If the ShowMessage variable is true, a textbox with its Visible property set to the ShowMessage variable will appear with your desired message like, "Please fill out all the required fields."

 

For more advanced errors besides required fields, I suggest reading up on the Errors function:

https://powerapps.microsoft.com/en-us/tutorials/function-errors/

 

You could combine that with the OnSuccess OnFailure properties of the Form.

 

Microsoft Employee
@8bitclassroom

View solution in original post

8 REPLIES 8
mr-dang
Level 10

Re: How do you make a field required?

Each "card" of the form should have a Required property that you can set to true/false. The same property can be seen for each card in View>Advanced if you select the Form Gallery itself.

 

The templates provided by PowerApps typically use some form of this code for a Button.OnSelect:

 

If(!IsBlank(TextInput1.Text) &&
!IsBlank(TextInput2.Text) &&
!IsBlank(TextInput3.Text),

SubmitForm(form),

UpdateContext({ShowMessage: true}))

 

This means that if all of the text input fields are not blank, then the button will Submit the Form. Otherwise, it will change the ShowMessage variable to true.

 

If the ShowMessage variable is true, a textbox with its Visible property set to the ShowMessage variable will appear with your desired message like, "Please fill out all the required fields."

 

For more advanced errors besides required fields, I suggest reading up on the Errors function:

https://powerapps.microsoft.com/en-us/tutorials/function-errors/

 

You could combine that with the OnSuccess OnFailure properties of the Form.

 

Microsoft Employee
@8bitclassroom

View solution in original post

yhijazeen
Level: Powered On

Re: How do you make a field required?

Hi,

 

Property "Is Required" is available, however, it doesnt work as expected.

I have a field which is required however, calling the Submit form via a button submits it with no issues even though the field in blank

Aaronpatel
Level: Powered On

Re: How do you make a field required?

Hi,
@ mr-dang. Thank you for posting the solution. The code you provided for button.OnSelect works great for a few item list. I have a list of over 40 items with app expanding to many pages. Is there a better option? It would be nice if I can just highlight the mandatory fields missing data. I can do that with a text input. But my app has drop-down and branching questions. Any help is appreciated!
Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: How do you make a field required?

Aaron, if you're using a form, you can just use

Form1.Valid

It returns true/false. It checks that all required fields are filled out.

 

Using it in a condition:

If(Form1.Valid,DisplayMode.Edit,DisplayMode.Disabled)

This means, "If Form1 is valid, make the button usable, otherwise disable it."

AaronPatel1
Level: Power Up

Re: How do you make a field required?

@mr-dang, Thank you for your suggestion.  I applied similar logic.  I marked the field as required (Required = true) and then added a Nofity(" ",Error) OnFailure and Navigate to the next screen OnSuccess. 

jpacettf
Level 8

Re: How do you make a field required?

@Mr-Dang-MSFT Re:Using this in a condition

 

What value would you put this against? OnSelect?

MK1
Level: Powered On

Re: How do you make a field required?

@mr-dang,

 

Can you help me with how to make lable,dropdown, textinput feilds  on a gallery screen required, whilie submitting the form.

 

Thanks,

MK1

Highlighted
Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: How do you make a field required?

@jpacettf, since the condition returns true or false, you can place it in many different places depending on how you want your experience. Below are the two most logical locations:

  • DisplayMode: you can use the condition to disable a button that submits a form
  • OnSelect: you can wrap the condition around the set of actions 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,742)