From 902dff94c155e1e62781af0a672dc8a2b9221116 Mon Sep 17 00:00:00 2001 From: Equus Date: Wed, 13 Dec 2017 15:30:27 +0100 Subject: [PATCH] Fix char counter bug --- js/charcount.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/charcount.js b/js/charcount.js index 5c33b70b..d613392d 100644 --- a/js/charcount.js +++ b/js/charcount.js @@ -1,3 +1,4 @@ + /* * charcount.js * @@ -16,14 +17,17 @@ $(document).ready(function(){ var $coundownField = $('#countchar'); var $maxChars = 6001; + if ($inputArea.length == 0) + return; + // Preset countdown field to max initial content length - $coundownField.text($maxChars - $inputArea.length); + $('.countdown').text($maxChars - $inputArea.val().length); // input :: for all modern browsers [1] // selectionchange :: for IE9 [2] // propertychange :: for