(function () {
var div, txt, timer;
div = document.getElementById('charcount');
txt = document.getElementById('inputfield');
txt.onkeyup = function () {
clearTimeout(timer);
timer = setTimeout(function () {
div.innerHTML = txt.value.length;
}, 10);
};
txt.focus();
})();