Wednesday, 29 August 2018

Count the Number of Words

How to Count/limit number of words entered by a user?

If you want to go beyond the basic restrictions or want to apply some more logical boundations then Regular Expression would be the right solution.

Below is the example to restrict the user to not enter more than 5 words.

Limit Words


if (xfa.event.newText.match(/\b\w+?\b/g).length > 5)

          xfa.event.change = "";
          app.alert("Maximum of 5 words are allowed");


No comments:

Post a Comment