How to check if a text is all white space characters in client side?

后端 未结 11 1169
心在旅途
心在旅途 2020-12-23 11:14

How to check if a user input text is all white space characters (space, tab, enter etc) in client side?

11条回答
  •  滥情空心
    2020-12-23 11:53

    Josh's answer is very close to this, but according to w3schools (in May 2014) it is as follows:

    function isEmpty(str) {
        return str.replace(/^\s+|\s+$/gm,'').length == 0;
    }
    

提交回复
热议问题