求网页上的ip输入框,要求用点分法表示。

joygxd 2004-04-23 10:17:12
点号不用输的那种

谢谢了
...全文
48 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
mark~
ice_berg16 2004-04-23
  • 打赏
  • 举报
回复
笨方法
<input name="ip1" type="text" id="ip1" size="3" onkeyup='check(this)'>
.
<input name="ip2" type="text" id="ip2" size="3" onkeyup='check(this)'>
.
<input name="ip3" type="text" id="ip3" size="3" onkeyup='check(this)'>
.
<input name="ip4" type="text" id="ip4" size="3" >
<script>
function check(ip)
{
nextip = eval("ip"+(parseInt(ip.name.charAt(2))+1));
if (ip.value.length == 3 || event.keyCode == 110 || event.keyCode == 190)
nextip.focus();
}

</script>
wanghr100 2004-04-23
  • 打赏
  • 举报
回复
模拟了一个.呵呵:)

<style>
.iptd {height:14px;width:24px;border:0;text-align:center}
* {font-size:10.5pt}
</style>
<table style="border:solid 1px">
<tr>
<td><input type="text" maxlength="3" class="iptd" name="ip1"></td><td>.</td>
<td><input type="text" maxlength="3" class="iptd" name="ip2"></td><td>.</td>
<td><input type="text" maxlength="3" class="iptd" name="ip3"></td><td>.</td>
<td><input type="text" maxlength="3" class="iptd" name="ip4"></td>
</tr>
</table>
Aa7643 2004-04-23
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<style>
.a3{width:30;border:0;text-align:center}
</style>
<script>
function mask(obj){
obj.value=obj.value.replace(/[^\d]/g,'')
key1=event.keyCode
if (key1==37 || key1==39)
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
if(obj.value.length>=3)
if(parseInt(obj.value)>=256 || parseInt(obj.value)<=0)
{
alert(parseInt(obj.value)+"IP地址错误!")
obj.value=""
obj.focus()
return false;
}
else
{ obj.blur();
nextip=parseInt(obj.name.substr(2,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
}
function mask_c(obj)
{
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))
}

</script>
<title>IP地址输入</title>

</head>
<body>IP地址输入
<div style="border-width:1;border-color:balck;border-style:solid;width:165;font-size:9pt">
<input type=text name=ip1 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip2 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip3 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip4 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>
</div>
</body>

</html>

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧