infopathsharepoint-designerinfopath2010

Limit number of words in the text box


I am new to Info path, I know how to limit the no.of characters entered in to the text box using string-length function. But is there any way we can limit the number of Words entered in to an multiline text box.

For example a field which is asking to enter 10 words are lesser


Solution

  • Found the answer and wanted to share it

    Set a Validation Rule for the field(textbox). In the condition select the "The expression" and type the below condition

    string-length(field)-string-length(translate(field," ","")) <10
    

    here field is the name of the textbox. And enter the text in the Screen Tip (Eg: Only lesser than 10 words) and click more option if you want ScreenTip and dialog box message. For testing in the preview type more then 10 words and hit tab the dialogue box with Only lesser than 10 words will appear