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

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

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

3 REPLIES 3
Highlighted
Super User
Super User

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

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

Highlighted
Frequent Visitor

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

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

Regular Visitor

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

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

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,190)