I have a form with multiple text entry fields. Some are input fields, and one is a textarea. I have the script (below) for a textarea in a form, to ensure that there is a max of 1500 characters. I am having two problems.
1) If there is an error on the form (for whatever reason), all of the text that was entered in the texarea, gets lost when the page reloads (this only happens for the textarea, the other input fields reprint the text).
2) When ever I try to press the "Tab" button on my keyboard, to tab out of the textarea to the next text box, it does not tab to the "next" text box, but instead it tabs "back" to the previous text box in the form.
Here's what I have:
<head>
<script type="text/javascript">
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}
</script>
</head>
<form>
<tr>
<td colspan="2"><textarea maxlength="1500" onkeyup="return ismaxlength(this)"
name="blah_post" tabindex="1" style="display: block; width: 340px; height: 150px;"
cols="60" rows="10" value="<?php print $blah_post;?>"></textarea></td>
</tr>
</form>
Don't remember where I found the script but, I'm open to more simpler javascript suggestions as well....