String.prototype.Trim = function(){return this.replace(/(^/s*)|(/s*$)/g, "");} String.prototype.LTrim = function(){return this.replace(/(^/s*)/g, "");} String.prototype.Rtrim = function(){return this.replace(/(/s*$)/g, "");} function check() { var test1=""; if(test1.Trim()=="") { alert("变量为空"); return false; } return true; }