3

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

  • Why don't you go with number of white spaces? If you can count number of white spaces you can easily count the words and go on... – Naveen Jun 25 '15 at 17:39
  • How do I do that, I tried using string-length(.) - string-length(translate(., " ","")) > 10 given herelink but that doesnot work – Info Jun 25 '15 at 17:52
  • string-length(field) - string-length(translate(field, " ", "")) should give you the number of white spaces. Try and let me know – Naveen Jun 25 '15 at 18:13
  • Thanks Naveen string-length(field) - string-length(translate(field, " ", "")) <10 works. The I did was I was tying more than 10 words in the text box thinking it will show ScreenTip while typing. But once i tab from the text box I get the ScreenTip – Info Jun 25 '15 at 18:53
  • But friend, i thought of putting that as answer once it had worked for you so that I would get few points. I was actually waiting for your comments on my suggestion. :) :) – Naveen Jun 26 '15 at 3:08
2

Try

string-length(field) - string-length(translate(field, " ", "")) < 10 which is inspired from KB Article

Formula to count the number of occurrences of a single character in one cell If you are concerned about searching for a single character in a single cell, the formula is simplified to: =LEN()-LEN(SUBSTITUTE(,"a",""))

Let me know if you have any questions.

1

I have received the correct answer from Microsoft Developers Network from Sathiya Kamalanathan. The validation which works is:

string-length(.) - string-length(translate(., " ", "")) > 10

I hope it will help others to solve similar problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.