X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/8fa5ac7024f21f7e57b8ce0a26152e578e6128b6..7dee9308d935fdd9829fcad64106d54473ac8ae0:/stage2/static/js/checktext.js diff --git a/stage2/static/js/checktext.js b/stage2/static/js/checktext.js new file mode 100644 index 0000000..d589f15 --- /dev/null +++ b/stage2/static/js/checktext.js @@ -0,0 +1,14 @@ +$(function() { + "use strict"; + var textarea = $("*[data-max-length]"); + textarea.before('

Pozostało:

'); + function updateCount(){ + var max_chars = this.getAttribute('data-max-length'); + var $this = $(this); + var remaining = max_chars - $this.val().length; + $("#count").text(remaining); + $this.prev().toggleClass('negative', remaining < 0); + } + textarea.on('input', updateCount); + textarea.trigger('input'); +});