用JAVASCRIPT限制TEXT字符串长度
<textareaname="remark"wrap="VIRTUAL"style="width:340px;"></textarea>是这个格式。我试过<textare...
<textarea name="remark" wrap="VIRTUAL" style="width:340px; "></textarea>
是这个格式。我试过<textarea name="remark" wrap="VIRTUAL" style="width:340px; " maxlength="100"></textarea> 也不行。谢谢高手指教。
哈哈asdfsafasfasfasf
adsf
asf
ad
fad
sfa
dsf
dasf
asf
afsd
dasf
asd
fasdfa
sdfadsf
asdf
asfasdfdasadsf
asdfadsf
asdf
sfasdaf
asdfasdfas
f
asdf
ads
ff
asfdsasf
fad
adsf
afsdafsdf
asdfadssdfad
sffaasdfas
adsfadsasf
sadfaasddf
asd
fasdf
asdf
ad
sa
afsd
dsafasfddsaf
ljasdf
lkjadsf
;kadsjf
k;dsahja
dfkhads
;kfaha
sdkhfa
;ksdhf
askhadfasdfkhfa
k;asdha
sdkhaf
;kafh
asdk;hfa
kasdfh
adsfkh
看看这个限不限制 展开
是这个格式。我试过<textarea name="remark" wrap="VIRTUAL" style="width:340px; " maxlength="100"></textarea> 也不行。谢谢高手指教。
哈哈asdfsafasfasfasf
adsf
asf
ad
fad
sfa
dsf
dasf
asf
afsd
dasf
asd
fasdfa
sdfadsf
asdf
asfasdfdasadsf
asdfadsf
asdf
sfasdaf
asdfasdfas
f
asdf
ads
ff
asfdsasf
fad
adsf
afsdafsdf
asdfadssdfad
sffaasdfas
adsfadsasf
sadfaasddf
asd
fasdf
asdf
ad
sa
afsd
dsafasfddsaf
ljasdf
lkjadsf
;kadsjf
k;dsahja
dfkhads
;kfaha
sdkhfa
;ksdhf
askhadfasdfkhfa
k;asdha
sdkhaf
;kafh
asdk;hfa
kasdfh
adsfkh
看看这个限不限制 展开
1个回答
展开全部
<script language="JavaScript">
function checkform(){
if(document.form1.remark.value.length <0 || document.form1.remark.value.length > 100){
alert("长度应为0-100个字符,请重新输入!");
document.form1.remark.focus();
return false;
}
}
</script>
<form name=form1 method="post" action="****" onSubmit="return checkform()">
</form>
其中form的名为form1,文本框的名为remark
function checkform(){
if(document.form1.remark.value.length <0 || document.form1.remark.value.length > 100){
alert("长度应为0-100个字符,请重新输入!");
document.form1.remark.focus();
return false;
}
}
</script>
<form name=form1 method="post" action="****" onSubmit="return checkform()">
</form>
其中form的名为form1,文本框的名为remark
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询