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

Stopping this "uuuuuuuuuuuuuu"

Explorer ,
Nov 13, 2007 Nov 13, 2007

Copy link to clipboard

Copied

I have a textarea in my form and I'm trying to stop users from entering long lines of text with no spaces. If they do, it expands my table off the page. I havent found away to make the line break within the table. I need some server side technique for assuring that a user uses spaces. So if a word is long than say 30 characters with no space I want to reject the post.

Any ideas? Thanks in advance!

I would also like to stop repeat characters in a row, like uuuuuuuuu. If anyone has an idea on how to stop that
TOPICS
Advanced techniques

Views

533

Translate

Translate

Report

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

Contributor , Nov 15, 2007 Nov 15, 2007
The easiest way would also be very basic. Loop over the content as a list with a delimiter of " " (space). Any other delimeters would not necessarily tell you if there was a long word because it could be part of the long word like uuuuu,uuuu

Then check the length of each part of the list.

So something like this:

<cfset test = "A BC DEF HIJK LMNOPQ">
<cfset tooLong = false>
<cfloop list="#test#" index="x" delimiters=" ">
<cfif LEN(x) GT 30><cfset tooLong = true></cfif>
</cfloop>

You could thr...

Votes

Translate

Translate
LEGEND ,
Nov 13, 2007 Nov 13, 2007

Copy link to clipboard

Copied

treat the user's text as a list with multiple delimiters - space, comma,
fullstop, colon, semi-colon, exclamation mark, question mark, etc - and
apply appropriate cf list functions to it to check the input for long
words and words with multiople repeated characters, though i would
probably not bother with the latter one myself...

---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Explorer ,
Nov 14, 2007 Nov 14, 2007

Copy link to clipboard

Copied

Azadi - I have looked through all the list functions and cant come up with a combination that will work to resolve my issue.
I would assume it would be a function that would look for a space and count characters after that space. Do you know of a cf function that will do this? Thanks

Votes

Translate

Translate

Report

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 ,
Nov 14, 2007 Nov 14, 2007

Copy link to clipboard

Copied

i was meant to edit my email to say just "functions" instead of "cf list
functions" before posting, but thn forgot... sorry....

what i had in mind was simple loop over multiple-delimiters-list and
check length of each list element.


---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Engaged ,
Nov 14, 2007 Nov 14, 2007

Copy link to clipboard

Copied

I wrote a blog entry on this awhile back using a built-in JRun class file. It may help you.

http://www.intersuite.com/client/index.cfm/2007/3/23/Buried-Utilities-JRun-wordWrap

Votes

Translate

Translate

Report

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
Advocate ,
Nov 14, 2007 Nov 14, 2007

Copy link to clipboard

Copied

Hi,

Try this 'differentChars' udf.

http://cflib.org/udf.cfm?ID=994

You can determine the bogus entry by the occurances returned by this udf.

Votes

Translate

Translate

Report

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
Guest
Nov 14, 2007 Nov 14, 2007

Copy link to clipboard

Copied

Are you also trying to keep users from entering URL addresses? Because these can easily be longer than 30 characters. If you break these up the link most likely won't work. Just thought I'd throw that out there...

Votes

Translate

Translate

Report

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
Explorer ,
Nov 14, 2007 Nov 14, 2007

Copy link to clipboard

Copied

Thanks everyone!

Yeah CFMXPrGrmR youre right I would make it a lot longer than 30.

C_wigginton, I checked that blog out and it looks like that wordwrap is what I'm looking for I'm going to give it a try tonight.

Daverms that udf looks good if I dont use it for this I'm definitely going to use if for passwords.

Azadi yeah now that I'm thinking about it I'm not sure its worth messing with the repeat characters, at least for this part.

Votes

Translate

Translate

Report

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
Contributor ,
Nov 15, 2007 Nov 15, 2007

Copy link to clipboard

Copied

The easiest way would also be very basic. Loop over the content as a list with a delimiter of " " (space). Any other delimeters would not necessarily tell you if there was a long word because it could be part of the long word like uuuuu,uuuu

Then check the length of each part of the list.

So something like this:

<cfset test = "A BC DEF HIJK LMNOPQ">
<cfset tooLong = false>
<cfloop list="#test#" index="x" delimiters=" ">
<cfif LEN(x) GT 30><cfset tooLong = true></cfif>
</cfloop>

You could throw in there some code to check if it is an email address or URL very easily. And of course you would change "test" for your variable.

Votes

Translate

Translate

Report

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
Explorer ,
Nov 18, 2007 Nov 18, 2007

Copy link to clipboard

Copied

LATEST
Dinghus - thanks for the sample! I think that should work perfectly

Votes

Translate

Translate

Report

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
Documentation