I'm trying to check if a string has white space. I found this function but it doesn't seem to be working:
function hasWhiteSpace(s)
{
var reWhiteSpace = new RegExp("/^s+$/");
// Check for white space
if (reWhiteSpace.test(s)) {
//alert("Please Check Your Fields For Spaces");
return false;
}
return true;
}
By the way, I added quotes to RegExp
.
Is there something wrong? Is there anything better that I can use? Hopefully JQuery.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…