cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Eric_at_CSG
Frequent Visitor

Change Text Input Control border color based on if it is blank or not

Hello, I am working with TextInput controls and Buttons.

 

I want to create a button that if the input is blank, they the border color will change to red, otherwise it will change to green.

 

The function I have for the Button OnSelect is:

 

If(IsBlank(TextInput1), TextInput1.BorderColor=Red, TextInput1.BorderColor=Green)

 

When I set Button1 to this, the border color of the TextInput1 control does not change.

 

My goal is to set required TextInput fields, that if left blank, will cause the border color to change so the user can identify them a little easier.

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Thorpe
Super User
Super User

You can't directly set property value from another another property or action. The properties are declarative, so what you need to do is use a variable in the property and then use the button to change the value of the variable.

 

Example:

Screen > OnVisible = Set(gvBorderColor, Black)

TextInput1 > BorderColor = gvBorderColor

Button > OnSlect = If(IsBlank(TextInput1), Set(gvBorderColor, Red), Set(gvBorderColor, Green))



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
Jeff_Thorpe
Super User
Super User

You can't directly set property value from another another property or action. The properties are declarative, so what you need to do is use a variable in the property and then use the button to change the value of the variable.

 

Example:

Screen > OnVisible = Set(gvBorderColor, Black)

TextInput1 > BorderColor = gvBorderColor

Button > OnSlect = If(IsBlank(TextInput1), Set(gvBorderColor, Red), Set(gvBorderColor, Green))



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

Thank you so much! I never thought about global variables for this problem. Worked like a charm. 

Is it possibe to increase or decrease the color RGBA value ever time the button is clicked?

JayashreeKrish
Resolver I
Resolver I

Hi @Jeff_Thorpe , When I try to set Border Color in Visible, it doesnot work. I am not able to set this color, Can u pls help ?

 

onVisible

JayashreeKrish_0-1628102287353.png

field border property

JayashreeKrish_1-1628102361980.png

 

Jeff_Thorpe
Super User
Super User

@JayashreeKrish , If you put your cursor on the line with Black, it should show the color black in the part you have circled. To get black to show up in the Border Color property you need to navigate to a different screen and then come back to trigger the OnVisible event of the screen.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,545)