宝玉 发表于 2003-4-8 09:06:16

IP地址输入框


<!--运行以下程序,在IP地址输入框中输入333试试?-->
<html xmlns:v="urn:schemas-microsoft-com:vml">

<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">
<title>IP-like Input</title>
<style>
<!--
v\:*            { behavior: url(#default#VML) }
div.IPDiv       { background: #FFFFFF; width: 120; margin:0; font-family: Arial,Tahoma; font-size: 10pt; text-align: center; border-top: 2 ridge threedshadow; border-left: 2 ridge threedshadow; border-right: 2 inset threedhighlight; border-bottom: 2 inset threedhighlight }
input.IPInput   { width: 24; margin:0; font-family: Arial,Tahoma; font-size: 10pt; text-align: center; border-width: 0 }

-->
</style>
</head>

<body bgcolor=threedface>
<div id="alertInfoDiv"  style="position: absolute; left:100; top:40; display:none">
                <v:roundrect strokecolor="black" fillcolor="infobackground" style="position:relative;left:30;top:5;width:130px;height:40px;z-index:9">
                        <v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow>
                        <v:textbox id="alertInfo" style="font-family:Arial,Tahoma;font-size:10pt;color:infotext;line-height:18px" inset="2px,2px,2px,2px"></v:textbox>
                </v:roundrect>   
                <v:oval strokecolor="black" fillcolor="infobackground" style="position:relative;left:-120;top:20;width:14px;height:10px;z-index:8">   
                        <v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow>   
                </v:oval>   
                <v:oval strokecolor="black" fillcolor="infobackground" style="position:relative;left:-160;top:32;width:10px;height:8px;Z-index:7">   
                        <v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow>   
                </v:oval>   
</div>
IP地址输入栏:  
<div style="position: absolute; left: 50; top:115; text-align: center; vertical-align: middle;">  
  
<script>   
IPlikeInputStr = "";   
IPlikeInputStr += '<div class="IPDiv">';   
for (i=0;i<4;i++) {   
  IPlikeInputStr += '<input class="IPInput" name="IPInput'+i+'" type="text" size="3" maxlength="3" onkeypress="keyHandle()" onkeyup="checkInput()">'+((i==3) ? '' : '.');   
}   
IPlikeInputStr += '</div>';   
document.write(IPlikeInputStr);   
   
function keyHandle() {   
  if (event.keyCode<48||event.keyCode>57) {   
    event.returnValue = false;   
  }   
}   
   
function checkInput() {   
  if (event.srcElement.name=="IPInput0") {   
    if (event.srcElement.value==0&&event.srcElement.value.length==3) {   
      event.srcElement.value="1";
      VMLAlert("请输入一个界于1和223之间的数值。",67);
      //alert("请输入一个界于1和223之间的数值。");   
      event.srcElement.select();   
    }   
    if (event.srcElement.value>223) {   
      event.srcElement.value="223";
      VMLAlert("请输入一个界于1和223之间的数值。",67);   
      //alert("请输入一个界于1和223之间的数值。");   
      event.srcElement.select();   
    }   
  }   
     
  else {   
    if (event.srcElement.value>255) {   
      event.srcElement.value="255";
      var theSrcName = event.srcElement.name;
      var theAlertPos = theSrcName=="IPInput1" ? 95 : (theSrcName=="IPInput2" ? 122 :150);
      VMLAlert("请输入一个界于0和255之间的数值。",theAlertPos);
      //alert("请输入一个界于0和255之间的数值。")   
      event.srcElement.select();   
    }   
  }   
}   

function VMLAlert(alertText,alertPos) {
  with (document.all) {
    alertInfo.innerHTML = alertText;
    alertInfoDiv.style.left = alertPos;
    alertInfoDiv.style.display = "";
  }
  setTimeout('document.all.alertInfoDiv.style.display = "none"',3000);

}   
</script>   
  
</div>   
   
</body>   
   
</html>

wish 发表于 2003-4-10 14:16:26

输入不了啊!提示有错误

冰天寒 发表于 2003-4-26 10:07:44

????

我还以为是查找ip地址程序,原来只是个判断而已啊!

Roman 发表于 2003-5-2 13:23:24

不错vml做的。

vku 发表于 2003-5-4 19:52:04

一个不错的东东

jinhuatang 发表于 2006-1-13 12:50:17

好啊

DJxiaoyang 发表于 2006-1-22 22:32:56

不错

wlb854854 发表于 2006-12-14 19:20:01

可以一表格里套4个textbox,设定一下样式,
也可以的啊...

zuijuya 发表于 2006-12-27 15:43:46

什么地方实用呢。?

hrjxfch 发表于 2007-3-6 12:12:49

xfdipzone 发表于 2007-3-16 17:27:05

按.不会自动跳到下个个输入框

mumu0726 发表于 2007-3-22 19:54:09

顶下~

scyyzgxh 发表于 2007-3-25 19:50:00

好东东/。。。。。

linzerd 发表于 2007-4-29 18:33:30

在加上"."切换就更完美了
参照Windows系统的IP设置

wudixin96 发表于 2007-5-2 16:23:27

还是不行啊。输入第一格后不会自动跳到第二格

wanghaojie5219 发表于 2007-5-10 08:44:17

要了

liuhaitao162005 发表于 2007-5-21 10:38:30

很好的测试小软件

wanghaojie5219 发表于 2007-5-21 15:50:18

好是好,但是功能上还有一点不足啊

xtyni 发表于 2007-7-3 14:28:27

是呀,有点麻烦。不过还是谢了。

ldy_2162 发表于 2009-5-4 11:38:23

还是有点不足,基本上可以。
页: [1] 2
查看完整版本: IP地址输入框