Results 1 to 2 of 2

Thread: [RESOLVED] Javascript Limit Text Help

  1. #1
    Join Date
    Dec 2008

    resolved [RESOLVED] Javascript Limit Text Help

    Hi, I use the below js to limit the amount of text allow in a textarea field. My problem is once the limit is reached I cannot delete anything that was type. How do I limit the textarea to a max length and still allow deleting when it reaches the max length?

    function limitText(Object, MaxLen)
    	{  return (Object.value.length <= MaxLen);}
    In the html
    HTML Code:
    onkeypress="return limitText(this, 250);"


  2. #2
    Join Date
    Dec 2012
    <script language="javascript" type="text/javascript">
    function limitText(limitField, limitCount, limitNum) {
    if (limitField.value.length > limitNum) {
    limitField.value = limitField.value.substring(0, limitNum);
    } else {
    limitCount.value = limitNum - limitField.value.length;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center