From 641f5124c7012098f99ce7f72907db7628078a3e Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 21 Mar 2015 23:53:06 -0400 Subject: [PATCH] Validation element insertion breaks counter (because plugin is looking for $elem.next()) Modifying the plugin to look for the counterCssClass among $elem siblings instead of $elem.next() - this way if validation inserts an extra label, span, etc. the plugin won't break. --- jquery.charactercounter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.charactercounter.js b/jquery.charactercounter.js index 0546330..2c1c316 100644 --- a/jquery.charactercounter.js +++ b/jquery.charactercounter.js @@ -87,7 +87,7 @@ function checkCount(element) { var characterCount = $(element).val().length; - var counter = options.counterSelector ? $(options.counterSelector) : $(element).next("." + options.counterCssClass); + var counter = options.counterSelector ? $(options.counterSelector) : $(element).siblings("." + options.counterCssClass); var remaining = options.limit - characterCount; var condition = remaining < 0;