I need to check to see if a variable is null or has all empty spaces or is just blank (“”).
I have the following, but it is not working:
var addr;
addr = " ";
if (!addr) {
// pull error
}
If I do the following, it works:
if (addr) {
}
What I need is something like the C# method String.IsNullOrWhiteSpace(value).
A non-jQuery solution that more closely mimics
IsNullOrWhiteSpace, but to detect null, empty or all-spaces only:…then:
* EDIT *
Please note that op specifically states:
So while yes, “white space” encompasses more than null, spaces or blank my answer is intended to answer op’s specific question. This is important because op may NOT want to catch things like tabs, for example.