Search code examples
jqueryjquery-validation-engine

javascript regular expression


I am doing validation using ValidationEngine plugin. But I need to validate a text area where the user should enter minimum 200 words to submit the form. (But its not mandatory field). So how do I customize this plugin. This plugin uses regex to validate the fields.


Solution

  • The regular expression to match n words followed by a .! or ? is:

    /(\w+\s){200,}\w+[.?!]/
    

    If you only want 200 words:

    /(\w+\s){200,}/
    

    Also see Regex to match sentences with at least n words