Add character count ffor the message field
authorLaury GvR <laury@gaslightmedia.com>
Mon, 27 Feb 2017 16:57:03 +0000 (11:57 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Mon, 27 Feb 2017 16:57:03 +0000 (11:57 -0500)
views/textArea.php

index ff5a791..c2dd36d 100644 (file)
@@ -1 +1,14 @@
-<textarea cols="40" rows="5" name="glmsimplemessageboard_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>
\ No newline at end of file
+<textarea class='message' cols="40" maxlength="270" rows="5" name="glmsimplemessageboard_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>
+<br><span class="countdown"></span>
+<script type="text/javascript">
+    function updateCountdown() {
+        // 140 is the max message length
+        var remaining = 270 - jQuery('.message').val().length;
+        jQuery('.countdown').text(remaining + ' characters remaining.');
+    }
+    jQuery(document).ready(function($) {
+        updateCountdown();
+        $('.message').change(updateCountdown);
+        $('.message').keyup(updateCountdown);
+    });
+</script>
\ No newline at end of file