3 Replies Latest reply on Dec 11, 2006 5:57 AM by tclaremont

    Limiting a string to 25 (or x) consecutive characters without a line break, space or tab.

    rob@whizbang.net Level 1
      We have users who will fill out a textinput with something like "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO" which blows up our page display. So I want to limit the number of characters they can submit without having some sort of break [\t \r \n \f]. I don't want to modify what they've input, I just want to return a variable to the template which calls the CFModule so that it can inform the users they need to go back and fix it themselves.

      What we do now is pass a text string & a numeric value which determines the max.number of characters w/o a break in the text. Right now I'm using a custom tag using Loops and find() statements (see attached code) to accomplish this. It works, but isn't as efficient as I'd like. Some of the strings we'll be checking can be quite long.

      I'd like to find a way to search for blocks of characters over 25 (or x) characters long that are not "break" characters such as a space, tab or carriage return. From what I can gather, ReReplace can use length parameters, but I've been unable to get it to do what I want it to do.
      Here's my ideal result:
      1. I could ReReplace any string over X characters without a break with a junk string (with a scope of one so we don't waste CPU)
      2. I would then search the string for any occurance of our new junk string.
      3. If the junk string exists, set Caller.ReturnVar to "Invalid"

      Does anyone have any thoughts or ideas? Is it possible to do this with the ReReplace tag or should I just stick to what I have? Any suggestions are greatly appreciated!

      Thanks,
      Rob