JS how to check empty String and Space
This question already has an answer here:
正则表达式可以轻松解决这个问题。
if (/^ *$/.test(value)) {
//string contains 0+ spaces only
}
I'm not sure I'm understanding correctly. Do you mean like:
if (value == "" || value == " "){
// do anything
}
链接地址: http://www.djcxy.com/p/27518.html
上一篇: 用js速记检查字符串
下一篇: JS如何检查空字符串和空格