cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Clear Text Input on Select?

Is it possible to clear the Default Text on a TextInput box OnSelect?  What I have is an app where data entry happens, but to save space I describe the data to enter in a given field inside the text entry box itself (by using Default).  Is there any way to clear the box OnSelect?  The Clear Button isn't really what I want, I want it to automatically clear when first selected, like may fields in the web do.

1 ACCEPTED SOLUTION

Accepted Solutions
hngdev
Resolver II
Resolver II

You can do something like this:

- Screen:

    - OnVisible: UpdateContext({maintext: "Text You Want To Show"})

- TextInput

    - OnSelect: UpdateContext({maintext: ""})

    - Default: maintext

View solution in original post

5 REPLIES 5
hngdev
Resolver II
Resolver II

You can do something like this:

- Screen:

    - OnVisible: UpdateContext({maintext: "Text You Want To Show"})

- TextInput

    - OnSelect: UpdateContext({maintext: ""})

    - Default: maintext

Anonymous
Not applicable

 

Ah, that did it! In fact, that also solved my secondary question of how to reset those when submitting.  I just redid the UpdateContext for OnSubmit of my button, and as soon as the submission completed, all my fields were back to default!  Perfect for a rapid intake form that needs no extra verification.

hpkeong
Community Champion
Community Champion

Hi

 

Just additional notes.

All TextInput comes with Reset.false/true. 

You can set to Reset.true

[UpdateContext({XX: " "}); UpdateContext({XX: ""}) is very flexible to use, too]

 

Capture.PNG

 

Just sharing in case you are using this.

 

Hope this helps.,

hpkeong

This code also does it:

 

[UpdateContext({XX: "", XY: "", XZ: ""})]

JMike
Microsoft
Microsoft

From what I understand, you want functionality equivalent to the HTML input 'placeholder' attribute. In that case, you'll want to use the TextInput control's HintText attribute, not the Default attribute. The accepted solution works ok, but there are a number of edge cases it does not account for. I'd recommend using the built in attribute for this.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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