自己写了一个方法,总是有问题。请大家给个比较全面和通用方法。
------解决方案--------------------------------------------------------
参考
<script language= "javascript ">
function check(zt,area)
{
zt = zt.replace(/ /g, " ");
if(zt== " " || zt.length <3)
{alert( "主题不能为空!或主题过短! ");
document.fom.zt.focus();
return false;}
if(area.length> 5000){
alert( "留言过多! ");
document.fom.area.focus();
return false;}
if(area== " "&&zt== " "&&tp== "http:// "){
alert( "空信息无法发出! ");
document.fom.area.focus();
return false;}
document.all( "ok ").style.display= "none ";
}
</script>
<html>
<head> ShowArticle </head>
<body>
title <br>
<form name= "fom " action= ".aspx " method=post>
标题 <input type=text name= "zt "> <br>
内容 <textarea name= "area " rows= "5 " cols= "60 "> </textarea> <br>
<input type=submit value= "确定 " onclick= "return check(zt.value,area.value) ">
</form>
</body>
</html>