function preventDefault(event) {
var e = event || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function judgeevent(e) {
e = e ? e : window.event;
var code = e.keyCode;
if ((code < 96 || code > 105) && (code < 48 || code > 57) && (code !=
&& (code != 46)) {
preventDefault(e);
}
}
function mask(obj){
key1=event.keyCode;
event.returnValue = true;
if((key1==110||key1==190)&&obj.value.length<=3&&obj.value.length>=1)
{
obj.value=obj.value.replace(/[^\d]/g,'');
nextip=parseInt(obj.name.substr(obj.name.length-1,1))+1;
nextip=nextip>=4?nextip-1:nextip; /*单方向右移*/
document.getElementById(obj.name.substr(0,obj.name.length-1)+nextip).focus();
document.getElementById(obj.name.substr(0,obj.name.length-1)+nextip).select();
}
obj.value=obj.value.replace(/[^\d]/g,'');
if (key1==37 || key1==39)
{
obj.blur();
nextip=parseInt(obj.name.substr(obj.name.length-1,1));
nextip=key1==39?nextip+1:nextip-1; /*单方向右移*/
//alert(nextip);
nextip=nextip>=4?nextip-1:nextip;
nextip=nextip<0?0:nextip;
//nextip=key1==37?nextip-1:nextip+1; /*循环移动*/
//nextip=nextip>=4?0:nextip
//nextip=nextip<0?3:nextip
//eval("serverip"+nextip+".focus()")
document.getElementById(obj.name.substr(0,obj.name.length-1)+nextip).focus();
}
if(obj.value.length>=3)
if(parseInt(obj.value)>=256 || parseInt(obj.value)<0)
{
alert(parseInt(obj.value)+"IP地址错误,请输入0-255之间的整数!")
obj.value=""
obj.focus()
return false;
}
else
{
obj.blur();
nextip=parseInt(obj.name.substr(obj.name.length-1,1))+1;
nextip=nextip>=4?nextip-1:nextip; /*单方向右移*/
//nextip=nextip>=4?0:nextip /*循环移动*/
//nextip=nextip<0?3:nextip
//eval("serverip"+nextip+".focus()")
document.getElementById(obj.name.substr(0,obj.name.length-1)+nextip).focus();
}
}
function mask_c(obj)
{
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''));
}