| Share this post! | Vote this! |
|
If you are setting up a form on your website you might want to limit the
length of the text that your users can type in a textarea so they can't
send you a poem for you to read.
HTML doesn't offer such a feature, but we can use javascript to check the text length and in case trim it. The user will also be shown the number of remaining chars.
We need to write a function that, each time that the user types a char, counts the number of chars and removes those exceeding the limit.
We'll use this function: it checks the lenth of the textarea content and if it's longer than the allowed limit, it trims the text to the chosen length. more...
HTML doesn't offer such a feature, but we can use javascript to check the text length and in case trim it. The user will also be shown the number of remaining chars.
We need to write a function that, each time that the user types a char, counts the number of chars and removes those exceeding the limit.
We'll use this function: it checks the lenth of the textarea content and if it's longer than the allowed limit, it trims the text to the chosen length. more...



0 comments:
Post a Comment