Created
March 14, 2014 17:11
-
-
Save EdCharbeneau/9552248 to your computer and use it in GitHub Desktop.
Javascript test a string to see if it is Null or Whitespace. Equivelent to C# String.IsNullOrWhiteSpace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isNullOrWhiteSpace(str) { | |
return (!str || str.length === 0 || /^\s*$/.test(str)) | |
} |
Thread resurrection here, but in case anyone stumbles upon this, I believe the answer Jeremygithub was looking for was:
String.prototype.isNullOrWhiteSpace = function() { return (!this || this.length === 0 || /^\s*$/.test(this)) }
if i have
@Html.EditorFor(m=>m. name) @Html.EditorFor(m=>m. lastname) how i defind that name is empty
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think a better name for this is: "isFalseyOrWhiteSpace"