This represents one word:
([a-zA-Z]+)
This represents one word followed by a single space:
([a-zA-Z]+\s)
This represents two or more:
{2,}
All together:
([a-zA-Z]+\s){2,}([a-zA-Z]+)
Two or more words followed by a single space then ending in a word.
Note: If you want a minimum of two words then change {2,}
to {1,}
.
In the demo if only 1 or 2 words are entered then submitted there should be an error popup. If 3 or more words are entered and then submitted, the whole form should disappear.
<form>
<input name='threeWords' type='text' pattern='([a-zA-Z]+\s){2,}([a-zA-Z]+)' required>
<input type='submit'>
</form>