文本框限制字数
答案:1 悬赏:40
解决时间 2021-03-06 06:58
- 提问者网友:低唤何为爱
- 2021-03-05 20:06
我在文本框中限制字数,但不知道怎么写,以下是我原来的,但只能一个条件,<br>function docheck() {<br> if (document.postform.name.value.length < 2) {<br> alert("缺少内容:需要输入您的大名");<br> document.postform.name.focus();<br> return(false);<br> }<br> if (document.postform.message.value.length < 2) {<br> alert("缺少内容或内容太长");<br> document.postform.message.focus();<br> return(false);<br> }<br> switchpost('postlayer');<br> document.postform.submit(); <br> return (true);<br>}<br><br>改成这样后就不行了<br>if (2 < document.postform.message.value.length < 401)<br>他是会提示"缺少内容或内容太长"<br>请问那位大虾帮个忙<br>曾至伟用你的不行。
最佳答案
- 二级知识专家网友:我颠覆世界
- 2021-03-05 21:04
function docheck() { <br>if (document.postform.name.value.length < 2) { <br>alert("缺少内容:需要输入您的大名"); <br>document.postform.name.focus(); <br>return(false); <br>} <br>if (document.postform.message.value.length < 2) { <br>alert("缺少内容"); <br>document.postform.message.focus(); <br>return(false); <br>} <br>if (document.postform.message.value.length > 401) { <br>alert("内容太长"); <br>document.postform.message.focus(); <br>return(false); <br>} <br>switchpost('postlayer'); <br>document.postform.submit(); <br>return (true); <br>}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯