How do I prevent only spaces in the text area? I don't want to allow only white spaces in the text area using HTML pattern or Validator.pattern
.
Asked
Active
Viewed 661 times
0

10 Rep
- 2,217
- 7
- 19
- 33

geekyLucifer
- 1
- 2
-
https://stackoverflow.com/questions/12568451/regex-pattern-for-contains-not-only-spaces, the pattern `.*[^ ].*` – Eliseo Oct 13 '20 at 08:06
-
added the $.trim() method – KashyapVadi Oct 13 '20 at 19:50
-
thanks @Eliseo that pattern worked – geekyLucifer Oct 14 '20 at 08:45
1 Answers
-1
You can use this regex for no spaces:
<form>
<input type="text" pattern="[^' ']+" />
</form>

MauriceNino
- 6,214
- 1
- 23
- 60

Arkalex
- 101
- 6
-
It blocks all the spaces btween the text. I want to restrict only spaces not spaces between text – geekyLucifer Oct 14 '20 at 08:39