JS_IP地址筐2
this.getValue = function(){
return document.getElementById(ipid+"ip1").value + "." +
document.getElementById(ipid+"ip2").value + "." +
document.getElementById(ipid+"ip3").value + "." +
document.getElementById(ipid+"ip4").value;
};
this.setValue = function(v){
if(v == "" || v==undefined)return;
var ss = v.split(".");
for(var i=0;i<ss.length;i++){
document.getElementById(ipid+"ip"+(i+1)).value = ss[i];
}
};
this.setDisabled = function(b){
for(var i=1;i<=4;i++){
document.getElementById(ipid+"ip"+i).disabled = b;
if(b)
document.getElementById(ipid+"ip"+i).style.backgroundColor="#F3F3F3";
else
document.getElementById(ipid+"ip"+i).style.backgroundColor="#FFFFFF";
}
if(b)
document.getElementById(ipid+"ip").style.backgroundColor="#F3F3F3";
else
document.getElementById(ipid+"ip").style.backgroundColor="#FFFFFF";
};
this.checkIp = function(){
var regex = /^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$/;
if(!regex.test(this.getValue()))
return false;
for(var i=1;i<=4;i++){
if(document.getElementById(ipid+"ip"+i).value > 255){
return false;
}
}
return true;
};
this.clearIp = function(){
for(var i=1;i<=4;i++){
document.getElementById(ipid+"ip"+i).value = "";
}
};
}