Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cftextarea -maxlength validation

Participant ,
Sep 14, 2006 Sep 14, 2006
I have a form field that is a <cftextarea> field that I would like to limit end users to only be able to enter 255 characters. I have tried the following:

<cftextarea name="lDescription" required="no" tabindex=5 class="boxbig"
style="height: 160px;" validate="maxlength" validateAt="onBlur" maxlength="255" message="The listing you have entered has exceeded 255 characters! The administrator may choose to condense the listing before making it available"><cfoutput>#Trim(Detail.lDescription)#</cfoutput></cftextarea>

But this only shows the warning when the user submits the form and saves the entire text to the db. Is there a way that I can limit the text that they type into the field so that it only allows the intended maximum characters or is this not possible with a textarea form field or a cftextarea form field? Thanks in advance and sorry if this is a simple problem.
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 14, 2006 Sep 14, 2006
http://www.dynamicdrive.com/dynamicindex16/maxlength.htm
HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com
Translate
Guest
Sep 14, 2006 Sep 14, 2006
You can always truncate the text to 255 characters on the action page.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 14, 2006 Sep 14, 2006
I want to be able to limit the text on the field so that the end user knows when they have reached the 255 character limit so that they do not have to count the characters on their own to see if they are within in the limit. I would be satisfied if when they exceeded the character limit that instead of proceeding to the action page when clicking OK on the warning message instead they would be taken back to the original form so that they could reduce the number of characters in the field. Is there a different type of form field that I should be using or different validation?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2006 Sep 14, 2006
I've accomplished this kind of thing with some simple javascript that
counts the characters in the text area and stops the submit if it is too
large. I've even augmented it so that is shows an live character count
next to the text area so that the user can see how many characters have
been typed or pasted into the field.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2006 Sep 14, 2006
http://www.dynamicdrive.com/dynamicindex16/maxlength.htm
HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 14, 2006 Sep 14, 2006
LATEST
quote:

Originally posted by: Newsgroup User
http://www.dynamicdrive.com/dynamicindex16/maxlength.htm
HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com



This worked, Thanks!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources