关于textarea超过一定字数,不能提交问题
2008-12-06 13:15
302 查看
<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" onsubmit="return CheckTextarea();">
<textarea rows="20" name="tsnr"></textarea>
<input type="submit" name="ok" value="ok" />
</form>
</body>
<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" onsubmit="return CheckTextarea();">
<textarea rows="20" name="tsnr"></textarea>
<input type="submit" name="ok" value="ok" />
</form>
</body>
相关文章推荐
- 关于ASP.NET中按钮提交后textbox不能赋值的问题
- Documentum常见问题2—压力测试时一旦用户数超过一定数量就不能登录了[转]
- 关于ListView+CheckBox,Item超过一屏时数据乱序和不能全部选中的问题
- 关于文件上传只能用表单提交而不能异步提交的问题
- 关于Flex 4 里 TextInput 和TextArea 不能输入中文的问题
- 关于editText和scrollView起冲突,editText内容超过编剧不能滑动的问题
- 关于ListView+CheckBox,Item超过一屏时数据乱序和不能全部选中的问题
- 关于安装.NET Framework SP1后不能正常提交的问题
- 关于input/textarea提交内容空格回车转换问题,以及ng-model去除空格问题
- 关于安装.NET Framework SP1后不能正常提交的问题
- 关于安装.NET Framework SP1后不能正常提交的问题
- Documentum常见问题2—压力测试时一旦用户数超过一定数量就不能登录了
- 文章标题文字超过一定字数省略号显示问题
- 关于项目中SVN不能更新和提交的问题
- 关于android 新浪微博进行oauth认证,提示“服务器提交参数错误”的问题
- 关于按回车键提交的问题
- 关于使用Eclipse导出jar文件时图片不能显示的问题
- 关于DDL控件提交后刷新问题