By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,944 Members | 1,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,944 IT Pros & Developers. It's quick & easy.

text area limitation

idsanjeev
100+
P: 241
i want to use fiexd text area with 500 characters is that possible and can use paragraph wise input in text area
Nov 13 '07 #1
Share this Question
Share on Google+
7 Replies


P: 9
Expand|Select|Wrap|Line Numbers
  1. var txtarea = document.getElementsByTagName("textarea")[0];
  2. var len = txtarea.length;
  3. if(len>500){
  4.     textarea.value = textarea.value.subString(0,500);
  5. }
  6.  
But I don't know what's the "paragraph wise" mean.
Nov 13 '07 #2

idsanjeev
100+
P: 241
hi where is the problem its not work
Expand|Select|Wrap|Line Numbers
  1. <script language = "javascript">
  2. var txtarea = document.getElementsByTagName("textarea")[0];
  3. var len = txtarea.length;
  4. if(len>500){
  5.     textarea.value = textarea.value.subString(0,500);
  6. }
  7.  
  8. function brvoice()
  9. {
  10.   window.location = "brvoice.asp"
  11. }
  12. function voice()
  13. {
  14.   window.location = "voice.asp"
  15. }
  16. </script>
  17. <td align='left'><textarea name="textarea" cols="50" rows="10"></textarea></td>
  18.  
Nov 19 '07 #3

gits
Expert Mod 5K+
P: 5,390
hi ...

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

kind regards
Nov 19 '07 #4

idsanjeev
100+
P: 241
hi how can put code in function and assing key handler.
Nov 21 '07 #5

idsanjeev
100+
P: 241
hi i am try to this but no insertion has been done
Expand|Select|Wrap|Line Numbers
  1. <script language = "javascript">
  2.   function counttxt()
  3.   {
  4.      var txtarea = document.getElementsByTagName("textarea")[0];
  5.      var len = txtarea.length;
  6.      if(len>500)
  7.      {
  8.        textarea.value = textarea.value.subString(0,500);
  9.      }
  10.    }
  11. </script>
  12. <td align='left'><textarea name="counttxt" cols="50" rows="10" onKeyPress="counttxt()"></textarea></td>
  13.  
Nov 21 '07 #6

100+
P: 428
subString is not a method name- javascript is caSe senSitive.
Nov 21 '07 #7

gits
Expert Mod 5K+
P: 5,390
yes :) ... it has to be substring() ...

kind regards
Nov 21 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.