Text Area - Calculate Characters

0
How to add a String calculator in Mindex in any text input? that can show the limit of characters the user can input and to validate that input?
asked
2 answers
2


You can put a token this way on the counter-message counter of the available characters and characters that were written at the bottom of the tool will appear automatically. 
  ​​​​​​​

answered
0

This works for you? It doesn't for me – nothing visible in the DOM, regardless of what value I set. Mind you, that's mendix 9.2. It might work in higher versions.

If you're working in mendix 8 or lower, I suggest wrapping the text input in a container. Add position relative to the styling of that conainer. In the container, above the text input widget, place a text widget that shows an attribute of the length. Make sure to add an on-change nanoflow that sets the proper length of the attribute to the text-input. Next, you only have to place a class on the text widget that shows your count. It should have position absolute, top x, right, x; Give it a nice color, and then you have a counter in your text input. This will work for all types of text input widgets.

 

This is what it looks like in real life, including the dom. The container has the class “input-with-counter”, and I have made sure you can see the styling of the counter itself.

Mind you, the input padding on right hand side will have to be increased, so the text of the counter will not overlap with the content of the field.

Hope this helps.

 

Best regards,

Wouter

answered