function checkSameNetMask(value1,value2,netmask) { var ip1 = new Array(); var ip2 = new Array(); var nm = new Array(); ip1 = value1.split("."); ip2 = value2.split("."); nm = netmask.split(".");
var ip1_2s = ""; var ip2_2s = ""; var inm2s = "";
var index = 0; for ( index = 0 ; index<4 ; index++ ) { var ip_1 = new Array(); var ip_2 = new Array(); var n_m = new Array(); ip_1 = parseInt(ip1[index]).toString(2); ip_2 = parseInt(ip2[index]).toString(2); n_m = parseInt(nm[index]).toString(2);
var len = inm2s.length; var ip_12 = new Array(); var ip_22 = new Array(); var n_m_2 = new Array(); ip_12 = ip1_2s.split(""); ip_22 = ip2_2s.split(""); n_m_2 = inm2s.split("");
for ( index = 0 ; index < len ; index++ ) { if(n_m_2[index] == "1") { if(ip_12[index] != ip_22[index]) { alert("不在同一网段"); return false;; } } } alert("在同一网段"); return true; }