posted 15 years ago
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.