<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-4490194096475053&dt=1228540492250&lmt=1228528450&prev_slotnames=1891601125&output=html&slotname=3685991503&correlator=1228540491796&url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F10%2F1821.html&ea=0&ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__98.html&frm=0&ga_vid=1085125342.1228540492&ga_sid=1228540492&ga_hid=2000129389&flash=9.0.124.0&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_java=true&dtd=15" frameborder="0" width="300" scrolling="no" height="250" allowtransparency></iframe>
1,<form action="a.jsp">
<textarea rows="20" name="111"></textarea>
<input type="submit" name="ok" value="ok" />
</form>
2,<form action="a.jsp" method="post">
<textarea rows="20" name="111"></textarea>
<input type="submit" name="ok" value="ok" />
</form>
然后你从网上复制一段文章下来,粘贴上去。发现如果textarea长度大于一定值的时候,
1不能提交,2能提交。
呵呵,原来1默认是get方式提交,get提交有字数限制,这就是为什么:一个表单中有textarea框,一旦内容超过几百字符后,点击提交页面无反应。少于这个数量即可正常提交。
脚本判断长度:
<script type="text/javascript">
function CheckTextarea() {
var regC = /[^ -~]+/g;
var regE = /\D+/g;
var str = document.forms[0].tsnr.value;
if (document.forms[0].tsnr.value.length>250){
alert("不能超过250个字符!");
document.forms[0].tsnr.focus();
return (false);
}
// 超过长度 , 截取提交 regC ;中文 regE: 字码
// if (regC.test(str)){
// document.forms[0].tsnr.value = document.forms[0].tsnr.value.substr(0,250);
// }
// if(regE.test(str)){
// document.forms[0].tsnr.value = document.forms[0].tsnr.value.substr(0,500);
// }
}
</script>
<body>
<form action="a.jsp" method="post" οnsubmit="return CheckTextarea();">
<textarea rows="20" name="tsnr"></textarea>
<input type="submit" name="ok" value="ok" />
</form>
</body>