To limit number of characters in the text area use Edit page: JavaScript onload event on the Eventstab. Here is a sample:
var ctrlFieldName = Runner.getControl(pageid, 'FieldName');
document.getElementById('counter').value = ctrlFieldName.getValue().length;
function func()
{
//update counter
document.getElementById('counter').value = ctrlFieldName.getValue().length;
//check if length of the entered value <40 characters
if (ctrlFieldName.getValue().length>40)
{
//show first 40 characters only
ctrlFieldName.setValue(ctrlFieldName.getValue().substr(0,40));
//update counter
document.getElementById('counter').value = 40;
}
}
ctrlFieldName.on('keyup', func);
where FieldNameis your actual field name.
To create counter switch toHTML mode on the Visual Editor tab and add following code just after your text area field:
<input type=text value=0 id=counter disabled="disabled" size=3>