郑爽调侃在娱乐圈地位:asp文本输入框限制 问题!!!请帮忙解决下!急!

来源:百度文库 编辑:高考问答 时间:2024/05/03 19:18:48
<tr><td colspan=3 height=30 align=center>
<table border=0 width='98%'>
<tr>
<td>
<table border=0>
<form action='?' method=get>
<input type=hidden name=action value='<%response.write action%>'>
<input type=hidden name=page value='<%response.write viewpage%>'>

<tr><td><table border=0 cellspacing=0 cellpadding=0 width='100%'><tr><td width=100 align=center height=20 bgcolor=<%response.write web_var(web_color,2)%> class=end><b>查询</b></td><td> </td></tr></table></td></tr>
<tr><td height=1 background='images/bg_dian.gif'></td></tr>
<tr>
<td><select name=sea_type size=1>
<option value='num'<%if sea_type="num" then response.write " selected"%>>按编号</option>
<option value='name'<%if sea_type="'name" then response.write " selected"%>>按姓名</option>
</select></td>
<td><input type=text name=keyword value='<%response.write keyword%>' size=15 maxlength=8 </td>

<td> <input type=submit value='搜 索'></td>

</tr>
</table>
</td>
</tr>
</table>
</td></tr>
<tr><td colspan=3 height=1 background='images/bg_dian.gif'></td></tr>

<tr><td>
<%

if rs.eof then
response.write "<p align='center'> 记录添加中......</p>"
else
call web_site_type()
end if
%></td></tr>
<tr><td height=1 background='images/bg_dian.gif'></td></tr>

</table>

上面是代码,如何在此查询中实现输入字数限制(不能少于8位字符)?而且让用户“只能输入整数数字”???

希望大家帮忙解决!谢谢!
非常感谢☆风花雪月☆提供的代码,只允许整数数字的功能已实现,但是我不知道把限制长度的代码放到哪里?能不能明确一些告诉我,路过有知道的,请赐教!!!

只能输入整形数字:
<input type=text name=keyword value="" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" onKeyPress="return check(event)">
<SCRIPT LANGUAGE=javascript>
<!--
function check(e)
{
if(((e.keyCode>=48)&&(e.keyCode<=57)))
{return true;}
else
{ return false;}
}

-->
</SCRIPT>

对于限制长度可以在提交前验证的代码里面处理:

if(form1.keyword.value.length<8)
{
alert("不能少于8位字符");
form1.keyword.focus();
return false;

}