用JavaScript实现的一个IP地址输入框,感觉不是太好,如果是192.168.1.1就必须输入192.168.001.001了别扭啊 .a3{width:30;border:0;text-align:center} 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