I'm using this Plugin to count chars on inputs and textareas: http://cssglobe.com/post/7161/jquery-plugin-simplest-twitterlike-dynamic-character-count-for-textareas
I would need to count characters also in a DIV with the setting "contentEditable" set to True.
Is this possible modifiying this Plugin?
I think I would need to change something in this line:
var count = $(obj).val().length;
But i really don't know how the contentEditable works... Any idea?
Thanks!
Edit:
I'm doing this as brettz9 suggested:
var method = $.inArray(obj.nodeName.toLowerCase(), ['textarea', 'input']) !== -1 ? 'val' : 'text';
var count = $(obj)[method]().length;
I just have one little problem on doing this for other field I required t have a min/max lenght (I have one input and one contentEditable)
This is that conditional part:
if (other_required){
if ($(other_required).val().length > 0 && available >= 0){
$(submit_button).attr("disabled", "");
} else {
$(submit_button).attr("disabled", "disabled");
}
i don't know how to declare that [method] var and use it with "other_required"