This simple JavaScript function will check a String to determine if it is blank. If the passed argument does not exist, has zero length, or just contains white space, then the function will return true.
function isBlank(str) { return (!str || 0 === str.length || /^\s*$/.test(str)); }