`
wurushuang
  • 浏览: 38814 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

javascript验证表单空字符串

阅读更多
<form action="<%=path%>/bbs.do?method=addBbs" method="post"   name="form1" target="_top" onsubmit="return checkForm();">   
<script type="text/javascript">   
function checkForm(){   
var title = $("#title").val().replace(/(^\s*)|(\s*$)/g,"");   
var content = document.form1.content.value.replace(/(^\s*)|(\s*$)/g,"");   
if(title.length < 5 ){   
alert("标题须大于5个字!");   
document.form1.title.focus();   
return false;   
//}   
 //else if(content.length < 5){   
 // alert("内容须大于5个字!");   
//  return false;   
 }else{   
return true;   
 }   
 }   
</script>  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics