i have one function which converts the ip/netmask into networkid/netmask and also it shows the message to user that his ip is changed to network id. but that function is working in mozilla perfectly but not in IE.
To check where is the fault i have written so many alert() but sometimes these are working.
Please someone read my code and tell me why its not working.
i am also sending you the function validateIPandNetMask()
my alert statement is commented so that one can understand my code
Expand|Select|Wrap|Line Numbers
- var enteredip;
- function validateIPandNetMask()
- {
- enteredip=document.addform.ipaddress.value
- firstvalue=document.addform.ipaddress.value;
- //alert("fstvalue="+firstvalue)
- ipnetmaskarr=firstvalue.split("/");
- ip=ipnetmaskarr[0];
- nm=ipnetmaskarr[1];
- //alert("ipnetmask0="+ipnetmaskarr[0]+"ipnetmask1="+ipnetmaskarr[1]);
- if(ipnetmaskarr[1]==null)
- {
- if(validateIPAddress(ipnetmaskarr[0]))
- {
- if(isBrowserIE())
- {
- window.returnvalue=addform.userid.value+'/'+addform.ipaddress.value;
- }
- else
- {
- opener.document.viewform.userid.value=document.addform.userid.value;
- opener.document.viewform.ipaddress.value = firstvalue;
- opener.document.viewform.mode.value = "<%=FWBMModes.ADD%>";
- opener.document.viewform.submit();
- }
- self.close();
- }
- else
- {
- alert("Enter a valid IP Address before proceeding");
- addform.ipaddress.focus();
- return false;
- }
- }
- else
- {
- //alert("ip= "+ip+" nm="+nm);
- if(validateIPAddress(ipnetmaskarr[0]))
- {
- if(validateIPNetmask(ipnetmaskarr[1]))
- {
- if(isBrowserIE())
- {
- window.returnvalue=addform.userid.value+'/'+addform.ipaddress.value;
- }
- else
- {
- //alert("ipnetmask0="+ipnetmaskarr[0]+"ipnetmask1="+ipnetmaskarr[1]);
- //alert("ippppp= "+ip+" nm="+nm);//In internet explorer this line is executed sometime
- var networkarr=new Array(4)//not ok
- //alert("ip= "+ip+" nm="+nm); //This alert is not working always
- iparr=ipnetmaskarr[0].split(".");//from this nothing is happening
- //alert("iparr="+iparr);
- nmarr=ipnetmaskarr[1].split(".");
- for(i=0;i<iparr.length;i++)
- {
- networkarr[i]=iparr[i]&nmarr[i];
- }
- networkid=networkarr.join(".")
- ipnmaddr=networkid+'/'+ipnetmaskarr[1]
- //document.getElementById('ipaddress').value=ipnmaddr;
- document.addform.ipaddress.value=ipnmaddr;
- if(firstvalue==ipnmaddr)
- {
- opener.document.viewform.userid.value=document.addform.userid.value;
- opener.document.viewform.ipaddress.value =document.addform.ipaddress.value
- opener.document.viewform.mode.value = "<%=FWBMModes.ADD%>";
- opener.document.viewform.submit();
- self.close();
- }
- else
- {
- // The networkid is displayed dynamically
- document.fgColor="red"
- var tbl = document.getElementById('tblgui');
- var lastRow = tbl.rows.length;
- if (lastRow >= 1)
- {
- tbl.deleteRow(lastRow - 1);
- var row = tbl.insertRow(lastRow-1);
- text = document.createTextNode("The IP address("+firstvalue+") is changed to networkid");
- row.appendChild(text)
- document.addform.ignore.disabled=false;
- flag=false;
- return false;
- }
- else
- {
- var row = tbl.insertRow(lastRow);
- text = document.createTextNode("The IP address("+firstvalue+") is changed to networkid");
- row.appendChild(text)
- document.addform.ignore.disabled=false;
- flag=false;
- return false;
- }
- }
- }
- }
- else
- {
- alert("Enter a valid NetMask before proceeding");
- addform.ipaddress.focus();
- return false;
- }
- }
- else
- {
- alert("Enter a valid IP Address before proceeding");
- addform.ipaddress.focus();
- return false;
- }
- }
- }