js如何判断textarea输入的内容不能为空或者全部为空格啊

史蒂芬-粥 2013-06-14 04:43:31
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
function saveThis(){
var subject = document.getElementById("subject").value;
var fatieContent = document.getElementById("fatieContent").value; alert("fatieContent:"+fatieContent.trim());
if(subject.trim() ==''){
alert("日志标题不能为空!");
return false;
}else if(fatieContent==''){
alert("内容不能为空!");
return false;
}

<textarea name="fatieContent" id="fatieContent" >
<s:property value="fatieContent" escape="false"/>
</textarea>

求指教关键是空格的处理
我输入了一排空格然后回车再空格 a 作为测试 其结果是

     </br>
     a


求高手解答
...全文
867 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
PuPPET ER 2013-06-17
  • 打赏
  • 举报
回复
<s:property value="fatieContent" escape="false"/> 把这里面的escape参数改为true 就不会出现 了

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧