cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Spawn10
Helper II
Helper II

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
Resolver III
Resolver III

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

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
Resolver III
Resolver III

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
Advocate I
Advocate I

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. 

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,551)