Js Char Count / Restrict.

Restrict char entry & Notify of char left. (nested).

HTML

<!-- textarea. -->
<textarea style="width: 364px; height: 149px;" class="required" id="desinp" name="desinp" maxlength="150"></textarea>

JavaScript

// Char limit.
function maxLength(el) {
  if (!('maxLength' in el)) {
    var max = el.attributes.maxLength.value;
    el.onkeypress = function() {
      if (this.value.length >= max) return false;
    };
  }
}

maxLength(document.getElementById("desinp"));

// Element style over-ride.
document.getElementById("desinp").style.color = "#ccc";
document.getElementById("desinp").style.resize = "none";
document.getElementById("desinp").style.height = "auto";
document.getElementById("desinp").rows = "3";