'IsNullOrWhitespace' in JavaScript?

后端 未结 8 1054
-上瘾入骨i
-上瘾入骨i 2020-12-02 22:22

Is there a JavaScript equivalent to .NET\'s String.IsNullOrWhitespace so that I can check if a textbox on the client-side has any visible text in it?

I\'d rather do

8条回答
  •  广开言路
    2020-12-02 22:43

    You must write your own:

    function isNullOrWhitespace(strToCheck) {
        var whitespaceChars = "\s";
        return (strToCheck === null || whitespaceChars.indexOf(strToCheck) != -1);
    }
    

提交回复
热议问题