diff --git a/html/sites/all/modules/maxlength/js/maxlength.js b/html/sites/all/modules/maxlength/js/maxlength.js
index ab6c60b..6e62615 100644
--- a/html/sites/all/modules/maxlength/js/maxlength.js
+++ b/html/sites/all/modules/maxlength/js/maxlength.js
@@ -55,7 +55,7 @@
    */
   ml.calculate = function(obj, options, count, wysiwyg, getter, setter) {
     var counter = $('#' + obj.attr('id') + '-' + options.css);
-    var limit = parseInt(obj.attr('maxlength'));
+    var limit = parseInt(obj.attr('data-maxlength'));
 
     if (count == undefined) {
       if (options.truncateHtml) {
@@ -75,6 +75,14 @@
       counter.removeClass(options.cssWarning);
     }
 
+    if ( available <= 0 ) {
+      obj.attr('maxlength', limit);
+    } else {
+      if ( obj.attr('maxlength') !== undefined ){
+        obj.removeAttr('maxlength'); 
+      }
+    }
+
     if (available < 0) {
       counter.addClass(options.cssExceeded);
       // Trim text.
@@ -264,6 +272,10 @@
       delete ml.options[$(this).attr('id')];
       return 'removed';
     }
+    
+    if ( $(this).attr('maxlength') !== undefined ){
+      $(this).attr('data-maxlength', $(this).attr('maxlength') ).removeAttr('maxlength'); 
+    }
 
     $(this).before('<' + options.counterElement + ' id="' + $(this).attr('id') + '-' + options.css + '" class="' + options.css + '"></' + options.counterElement + '>');
     ml.calculate($(this), options);
