Hi Gary,
I'd be more inclined to do it slightly differently... in a Form Load rule:
$(document).on('keyup', '#demo3', function (event) {
var maxLength = $(event.target)[0].maxLength;
var fldLength = $(event.target)[0].value.length;
$('.id-chars').text((maxLength-fldLength) + ' characters remaining');
});
There's a couple of advantages:
I have a Text Field that only allows 20 characters, and I want to display a countdown message as the user enters values in the field. I have it working based on the following approach but was wondering if there was a more elegant solution?
My Text Field (i.d. demo3) has the following code in a Focus Rule
In my Text Display, I edit the source to include an id (chars) so that the reference works in the above script :
While this seems to work fine, I was just wondering if there was another way of approaching this?
Thanks