Can some one help me whether my java script code for IP Address validation is correct or not? I am using a regular expression that does not allow any other special characters other than dot and also does not allow non-numeric characters.I am trying to validate IP Address in web page, loaded in our Modem.IP address is not getting validated when web page is loaded in modem.Please find code snippet and help me in resolving this issue...
function chkIPV4()
{
for(x=0;x<txtBox.length;x++)
{
var ip4add = document.getElementById(txtBox[x]).value;
var name=txtBox[x];
var chk_arr = ip4add.split(".");
if(chk_arr.length != 4)
{
alert(name +" is not Valid");
return false;
}
for(var i=0; i < chk_arr.length; i++)
{
if( !(/^\d+$/.test(chk_arr[i])))
{
alert(name +" is not Valid");
return false;
}
else if( chk_arr[i] < 0 || chk_arr[i] > 255)
{
alert(name +" is not Valid");
return false;
}
}
}
return true;}