-2

i need check my textarea maxlength of character. But i need check that by javascript. This is my code

<script>
  function checkform(form) {
   if(document.filter.myarea.value.length > 255) {
     alert("Maxlength is 255!");
     return false;
    }
     return true; 
 }  
</script>
<form method="post" name="filter" onsubmit="return checkform(this);">
 <textarea name="myarea">Some text</textarea>
</form>

Why this isn t working ? thank you

Bopinko
  • 15
  • 1
  • 8

1 Answers1

0
<script>
  function checkform(form) {
   if(document.filter.myarea.value.length > 255) {
     alert("Maxlength is 255!");
     return false;
    }
     return true; 
 }  
</script>
<form method="post" name="filter" onsubmit="return checkform(this);">
 <textarea name="myarea" id="myarea">Some text</textarea>
</form>

add id attribute to area should work.