This content has been marked as final. Show 9 replies
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...
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...
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.
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
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.
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>
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.
Dinghus - thanks for the sample! I think that should work perfectly