cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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

Highlighted

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
Highlighted
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

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

Highlighted

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

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,550)