I have Required
attribute for some strings in my view model, but that doesn't catch if user types, say, (yes, whitespace) into the text area. I need to prevent user to submit whitespace-only strings.
I am trying to use RegularExpression
attribute on my view model's properties to validate the string. I've seen some answers such as Filtering "whitespace-only" strings in JavaScript or How to validate whitespaces using jquery/ajax in an MVC view but they don't seem to work properly (yes, before you ask, I am omitting leading and trailing /
s if I'm taking it from Javscript to C#). The examples at the answers to those questions usually validate only against whitespace, or no whitespace at all. What I need is that I need at least some text to validate. Having some whitespace is no problem as long as I also have some non-whitespace string too.
What regex should I use (I am not good with regexes) in my attribute to validate some text that contains at least some non-whitespace text?