var max = 400;

function myInText(el,str)
{
  if(el.innerText!=null)
   el.innerText = str;
  else
   el.textContent = str;
}

function checkLen() 
{
    if (document.all) {
       str = f1.text.value;
       len = str.length;
    }
    else{
        str = document.forms.f1.text.value;
        len = document.forms.f1.text.textLength;
    }
    var rusLen = 0;
    fullLen = max - rusLen;
   	if ( len > fullLen) document.forms.f1.text.value = str.substring(0,fullLen);
	myInText(document.getElementById("l"),"Осталось "+(fullLen - document.forms.f1.text.value.length)+" символов");
	document.forms.f1.text.focus();
 }