4 Replies Latest reply on Feb 17, 2015 11:05 AM by BrianWoods

    Field Validation

    BrianWoods

      Title

      Field Validation

      Post

      I'm trying to prevent (or at least discourage) users from entering ANY of several words in a given field. Let's suppose I'm trying to prevent people from entering conjunctions..."and", "but", "or", "for", "since", etc.   So whether they type one or multiple prohibited words, there should be an error message. 

      Using the Field Validation Options for a single word, I've been successful specifying the following calculation: PatternCount( Self; "and"  = 0).

      Trying to incorporate more words, it seems the Case function would be appropriate.  However, I haven't had any success:

               Case(
               PatternCount( Self; "and" = 0;
               PatternCount( Self; "but"  = 0;
               PatternCount( Self; "or"  = 0;
               PatternCount( Self; "for"  = 0;
               PatternCount( Self; "since"  = 0
               )

      Any quick fixes?  Or thoughts on approaching this differently?

      BTW, I've checked:

               "Only during data entry"

               "Allow user to override during data entry"

               "Display custom message if validation fails".

               "Validate only if field has been modified".

        • 1. Re: Field Validation
          philmodjunk

          I'm not a big fan of field validation except for certain specific tasks where it serves more as an "insurance policy" to back up other validation methods. I prefer scripted validation as I can design the interface to respond to different data entry errors more flexibly and present the user with more user friendly options for correcting errors.

          But your expression would need to look like this:

                   PatternCount( Self; "and" ) = 0 and
                   PatternCount( Self; "but" ) = 0 and
                   PatternCount( Self; "or" ) = 0 and
                   PatternCount( Self; "for" ) = 0 and
                   PatternCount( Self; "since" ) = 0

          All of the patterncount tests have to be true. You want an error message to pop up if any one of the tests fail.

          But the above calculation still needs work. Text such as "Stand" will cause the first pattern count test to be false and "Door" would cause the third test to be false.

          Here's a start and solving those issues, but may not be sufficient for all possible text entries or could be overkill for what you need:

          Let ( TheText = " " & Substitute ( self ; ["." ; " " ] ; [¶ ; " " ] ; ["," ; " "] ; ["!" ; " " ] ; ["?" ; " " ] ) & " " ;
                   PatternCount( TheText ; " and " ) = 0 and
                   PatternCount( TheText ; " but " ) = 0 and
                   PatternCount( TheText ; " or " ) = 0 and
                   PatternCount( TheText ; " for " ) = 0 and
                   PatternCount( TheText ; " since " ) = 0
               ) // Let

          • 2. Re: Field Validation
            RickWhitelaw

            Hard coding these words seems a problem to me. What about "if" or "than" for example? I don't have a better solution for you, bu it seems to me the list of prohibited words could become quite lengthy when you think about it. There is probably a limited number of conjunctions and you could easily find those words, but are you intending to limit only conjunctions?

            • 4. Re: Field Validation
              BrianWoods

              Thanks Phil.  Your help, insight and advice are always greatly appreciated.  I will try my hand at incorporating this into scripts instead.

              Rick, I am trying to prohibit certain words...not necessarily conjunctions.  I was using conjunctions as an example.  With that said, you're right that there's a large (and seemingly infinite) set of words that would need to be addressed. I realize there's no way I can address every possibility.  For my solution, however, I believe I can remove 95% to 99% of problems by prohibiting the most commonly used "no-no" words.