cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NBMS_2019
Helper II
Helper II

Counter for a multiline textbox

Looking for a solution to add a counter for a multiline textbox so while a user is typing, the counter will show how many characters are left out of n characters.

 

Thanks for any help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
iAm_ManCat
Super User
Super User

Heya!

 

Yes we can definitely do that - Label's text would be something like:

 

 

 

//max characters minus
400 - 
//current number of characters in textinput
Len(textinput1.text)
&
" characters left"

 

 

 

We can also set the MaxLength property of the control to 400 (or whatever your limit should be) and instead use:

 

//max characters minus
TextInputControlName.MaxLength - 
//current number of characters in textinput
Len(textinput1.text)
&
" characters left"

 

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

TheRobRush
Super User
Super User

in its visible put

 

Len(textinput1.text)>0
_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

View solution in original post

10 REPLIES 10
iAm_ManCat
Super User
Super User

Heya!

 

Yes we can definitely do that - Label's text would be something like:

 

 

 

//max characters minus
400 - 
//current number of characters in textinput
Len(textinput1.text)
&
" characters left"

 

 

 

We can also set the MaxLength property of the control to 400 (or whatever your limit should be) and instead use:

 

//max characters minus
TextInputControlName.MaxLength - 
//current number of characters in textinput
Len(textinput1.text)
&
" characters left"

 

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


TheRobRush
Super User
Super User

.

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

The problem with this implementation is that they can't then backspace to correct their text once it goes over the limit, I would just set the MaxLength property for the multiline to 400 or whatever the limit should be, then in my code instead of using 400 you can use ControlName.MaxLength

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Is this not duplicating the maxlength property's functionality?

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


TheRobRush
Super User
Super User

Haha, you are 100% right, I haven't had my coffee yet. Ignore ALL  of that and just set max length and reference that like @iAm_ManCat said 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

😂 I am at the end of a very coffee filled day (cats woke me up at 5) so I totally understand

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Thank you for this, it is working but how can I hide this label until they click or start entering in the textbox? I know how to make it invisible but struggling to make OnSelect work.

TheRobRush
Super User
Super User

in its visible put

 

Len(textinput1.text)>0
_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

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.

Users online (3,900)