Hii @kartik,
Returning from one function doesn't call as it's end, much less use a specific return value.
If you want to do that, you have to set a variable that the outer function will use:
checkipAddress = function(value){
var rv = true; // <=== Default return value
var array = value.split('.');
$.each(array, function(index,val){
if(parseInt(val)>255)
return rv = false; // <=== Assigns false to `rv` and returns it
});
return rv; // <=== Use rv here
}
Your function will happily allow IP strings like "0.-234343.-1.0" and "1foo.2foo.3foo.4foo".
You might consider:
checkipAddress = function(value){
var rv = true; // <=== Default return value
var array = value.split('.');
$.each(array, function(index,str){
str = $.trim(str);
var val = +str;
if(!str || val < 0 || val > 255)
return rv = false; // <=== Assigns false to `rv` and returns it
});
return rv; // <=== Use rv here
}
Hope it helps!!