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


Snippet:

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

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


Source: https://www.dropbox.com/s/a0vy1z1yvne7ut3/limit%20to%205%20words.pdf?dl=0

No comments:

Post a Comment