You can't do it with HTML directly.

Most people use JavaScript handlers to do this.
<script>
  function checkStuffLength(aField) {
     if (aField.value.length > 1024) {
        alert('sorry, only 1024 characters allowed in field '+aField.name);
        aField.value = aField.value.substr(1,1024);
     }
  }
</script>
<textarea name=myStuff onchange="checkStuffLength(this)"
onblur="checkStuffLength(this)"></textarea>

-----Original Message-----
From: Stephen, Prem Kumar [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 19, 2001 1:36 PM
To: [EMAIL PROTECTED]
Subject: HTML Q: length validation in a textarea field


I am not sure if I can pose this Q here...

One of my jsps has a textarea field that should accept a max of 1024
characters.

I am able to set this in a text field using <checked maxlength="" >
 How do I do it using textarea?

TIA
Prem

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to