cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

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
Community Champion
Community Champion

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

11 REPLIES 11
Community Champion
Community Champion

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

Anonymous
Not applicable

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

Helper I
Helper I

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!

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."

@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. 

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

 

What value would you put this against? OnSelect?

Helper IV
Helper IV

@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

@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 

Hi,

 

Can you perform this if  you have just a sheet with TextInputs? i.e no forms?

how will I handle errors where TextInputs have no data on Submission

 

Thanks

 

Dan

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (20,556)