What would be the regular expression to apply so that in a textarea, if you write only blank spaces, it does not validate it?
Right now I have the condition that it does not validate the textarea if nothing has been written, that is:
if (textarea === ''){}
As they tell you, you could simply use
trim()
:Or use one
Regex
:Checking the content of a text box (and other types of text fields) is really frequent, so to avoid repeating validation code every time you need it, you can use a function that evaluates if the content of your text box (or any other control that serves to enter text) is NULL (nothing was typed) or just blank characters:
Where textSent would be the content of your text box