• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

How to prevent user from typing into TEXTAREA

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I have a text area which accepts user input.
I need to limit the user to type no more than 1000 chars.
Typically this is what I want to achieve:
1. User starts typing.....
2. Once 1000 chars reached, an alert is shown that 'Maximum limit reached'
3.If the user types further nothing appears.

Code:
if (str.length > 1000){
alert('Comments can only be up to 1000 characters, everything after has been truncated.');
return false;

The above code shows the dialog fine but still allows the user to go on typing.
I want to the user to not be able to type anything after the error is thrown.
Please help.

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should be plenty of results out there:

max length textarea

Eric
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic