Character count - help

Hey guys,

In the profile section for our users we have them entering a description of themselves. I currently have it set to a 200 character max length. For a good user experience, I want to include a count down of how many characters they have left as they type (max length - current length).

What’s the best way to put this together? Could you guys help me with this? I can’t seem to get something like this working, but it seems pretty simple.

Thanks so much! - Ryan

			var Observable = require("FuseJS/Observable");
			var inTxt = Observable("");
			count ={return 200 - e.length;});
			module.exports = {inTxt, count}
		<TextBox Dock="Top" Value="{inTxt}"/>
		<Text Value="Remaining chars: {count}"/>

You are the man! Perfect.

So I changed it around a bit as I actually have a pre-populated description that is being pulled from the database, but the user can edit. I then pass Description = “{description}” in my ux on actual setting page which pulls the description from the server. Just in case anyone is doing something similar, my code looks like this:

<Panel ux:Class="CharacterCount">
	<string ux:Property="Description" />
	    var Observable = require("FuseJS/Observable");
	    var Value ={
	    	return 180 - x.length;

	    module.exports = {
	    	Value: Value
	<Text Value="{Value}" FontSize="12" />

My question now is… how would I could I change the font color to become red when the character count is less than 20?

if (Value.value < 20){

Something that like clearly doesn’t work.

Like this:

 var color = { return c > 20 ? "Red" : "Blue"; });

Then you databind that to Color on the text