if (!text || text .length < 2 || !/^[a-zA-Z\s]+$/.test(text)) { }
This regex ensures:
The input consists only of letters (both uppercase and lowercase) and spaces.
The minimum length is 2 characters.