Javascript to limit maximum length of textarea

<textarea cols="40" rows="8" name="alerttext" onkeypress="return imposeMaxLength(event, this, 249);" id="editor1"></textarea>

<script type="text/javascript">

function imposeMaxLength(Event, Object, MaxLen)

{

return (Object.value.length <= MaxLen)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40))

}

</script>