Skip to content

Commit

Permalink
Validation element insertion breaks counter (because plugin is lookin…
Browse files Browse the repository at this point in the history
…g 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.
  • Loading branch information
wardtwits committed Mar 22, 2015
1 parent 575391b commit 641f512
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jquery.charactercounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 641f512

Please sign in to comment.