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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (4,594)