text area limitation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idsanjeev
    New Member
    • Oct 2007
    • 241

    text area limitation

    i want to use fiexd text area with 500 characters is that possible and can use paragraph wise input in text area
  • Fisher ma
    New Member
    • Nov 2007
    • 9

    #2
    [code=javascript]
    var txtarea = document.getEle mentsByTagName( "textarea")[0];
    var len = txtarea.length;
    if(len>500){
    textarea.value = textarea.value. subString(0,500 );
    }
    [/code]

    But I don't know what's the "paragraph wise" mean.

    Comment

    • idsanjeev
      New Member
      • Oct 2007
      • 241

      #3
      hi where is the problem its not work
      Code:
      <script language = "javascript">
      var txtarea = document.getElementsByTagName("textarea")[0];
      var len = txtarea.length;
      if(len>500){
          textarea.value = textarea.value.subString(0,500);
      }
      
      function brvoice()
      {
        window.location = "brvoice.asp"
      }
      function voice()
      {
        window.location = "voice.asp"
      }
      </script>
      <td align='left'><textarea name="textarea" cols="50" rows="10"></textarea></td>

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        you should put the code in a function and assign a keypress handler to your textarea that calls the function ...

        kind regards

        Comment

        • idsanjeev
          New Member
          • Oct 2007
          • 241

          #5
          hi how can put code in function and assing key handler.

          Comment

          • idsanjeev
            New Member
            • Oct 2007
            • 241

            #6
            hi i am try to this but no insertion has been done
            Code:
            <script language = "javascript">
              function counttxt()
              {
                 var txtarea = document.getElementsByTagName("textarea")[0];
                 var len = txtarea.length;
                 if(len>500)
            	 {
                   textarea.value = textarea.value.subString(0,500);
                 }
               }
            </script>
            <td align='left'><textarea name="counttxt" cols="50" rows="10" onKeyPress="counttxt()"></textarea></td>

            Comment

            • mrhoo
              Contributor
              • Jun 2006
              • 428

              #7
              subString is not a method name- javascript is caSe senSitive.

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                yes :) ... it has to be substring() ...

                kind regards

                Comment

                Working...