Commit 1e0df4bc authored by felix.herrmann's avatar felix.herrmann
Browse files

feat(maxlength): set new div to empty if chars are deleted under maxlength-50

parent 21147f9b
......@@ -166,18 +166,24 @@ $(document).on('keyup','.textarea, .textinput', function() {
var remainingLength = maxLength-length;
// get this elements id
var elemId = $(this).attr('id');
// construct new id using this elements id
var charsLeftId = elemId + '_chars_left';
if (remainingLength < 50) {
// construct new id using this elements id
var charsLeftId = elemId + '_chars_left';
if ($('#' + charsLeftId).length) {
// if new div exists set text
$('#'+charsLeftId).html(remainingLength);
$('#'+charsLeftId).text(remainingLength);
}
else {
// create new div using new id
$("<div class='chars-left' id='" + charsLeftId + "'>" + remainingLength + "</div>").insertAfter('#' + elemId);
}
}
else {
// if chars are deleted and remainingLength > 50 make new div empty
if ($('#' + charsLeftId).length) {
$('#'+charsLeftId).text('');
}
}
}
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment