Skip to content

Commit

Permalink
Parse HTML5 attributes for max length
Browse files Browse the repository at this point in the history
Added check during instantiation to look for HTML5 maxLength attribute and set that as the limit if found.
  • Loading branch information
ChrisMagellan committed Feb 16, 2015
1 parent 2d7945a commit 0d99a18
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions jquery.charactercounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
var options = $.extend(defaults, opts);

return this.each(function() {
var html5len = $(this).attr('maxlength');
if (typeof html5len !== typeof undefined && html5len !== false) {
$.extend(defaults, {
limit: parseInt($(this).attr('maxlength'))
});
}
if (!options.counterSelector) {
$(this).after(generateCounter());
}
Expand Down

0 comments on commit 0d99a18

Please sign in to comment.