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

How do I prevent a submit button from executing, if a required field is blank?

I am using a scrollable screen and have a ton of fields I use to collect data from the user. I am currently patching the data into a SharePoint list, when the user clicks on a submit button...after scrolling through the page and entering data. Without using the "required field" column on the SharePoint end, I want to be able to prevent the user from being able to submit the data if they have not entered data for a required field. This is what I am doing right now...

If(
    !IsBlank(textbox_1.Text) && !IsBlank(dropdwn_1.Selected.Value) && !IsBlank(radioBtn.Selected.Value), Set(BorderColor, Black), Set(BorderColor, Red)
);
Patch (

)

the problem with this approach is, regardless if there is a required field entered or not, the patch action always executes. What am I doing wrong here, and what is the best way to prevent the patch action from being executed if a required field is left blank?

2 ACCEPTED SOLUTIONS

Accepted Solutions
myke_deabreu
Level 8

Re: How do I prevent a submit button from executing, if a required field is blank?

on your button - use the DisplayMode function and do this:

 

If(
!IsBlank(textbox_1.Text) && !IsBlank(dropdwn_1.Selected.Value) && !IsBlank(radioBtn.Selected.Value),DisplayMode.Edit,DisplayMode.Disabled)

 

This will grey out the button till the condition is met.

View solution in original post

Spawn10
Level: Powered On

Re: How do I prevent a submit button from executing, if a required field is blank?

I ended up using this syntax, and it worked for me...

If(IsBlank(textbox_1.Text) || IsBlank(dropdwn_1.Selected.Value) || IsBlank(radioBtn.Selected.Value), Set(gvBorderColor, Red), Patch ())

View solution in original post

3 REPLIES 3
myke_deabreu
Level 8

Re: How do I prevent a submit button from executing, if a required field is blank?

on your button - use the DisplayMode function and do this:

 

If(
!IsBlank(textbox_1.Text) && !IsBlank(dropdwn_1.Selected.Value) && !IsBlank(radioBtn.Selected.Value),DisplayMode.Edit,DisplayMode.Disabled)

 

This will grey out the button till the condition is met.

View solution in original post

BluRonnie
Level: Powered On

Re: How do I prevent a submit button from executing, if a required field is blank?

You can setup required fields in powerapps instead, and also put the patch into OnSuccess of the form. So even the user wants to submit the form without required fields, they will get error notified and the patch will only be executed after form submit successfully, ie all the required fields have values. 

Spawn10
Level: Powered On

Re: How do I prevent a submit button from executing, if a required field is blank?

I ended up using this syntax, and it worked for me...

If(IsBlank(textbox_1.Text) || IsBlank(dropdwn_1.Selected.Value) || IsBlank(radioBtn.Selected.Value), Set(gvBorderColor, Red), Patch ())

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 420 members 6,668 guests
Please welcome our newest community members: