1. Determine whether the string is an empty character, that is, the user has entered a space
var strings = ' ';
if (strings.replace(/(^s*)|(s*$)/g, "").length ==0){
alert('不能为空');
}
2、判断字符串是否都是空格
function isNull ( str ) {
var regu = "^[ ]+$";
var re = new RegExp(regu);
return re.test(str);
}
Reference article: https://www.jb51.net/article/86543.htm