...

View Full Version : jQuery IP Validator



phantom007
02-16-2009, 11:41 AM
Hi

I was wondering if its possible to check an IP address format with this jQuery plugin?

http://digitalbush.com/projects/masked-input-plugin/#usage

If yes, how? If not, is there any other jQuery Plugin for it?

Thanx in advance

Philip M
02-16-2009, 11:55 AM
I don't see why not (but you could try it out!).

Or use this:-



<script type = "text/javascript">
var ip = "129.31.1.10";
var valid = true;
var ipsub = new Array();
ipsub = ip.split(".");
for (var i = 0; i <ipsub.length; i++) {
var sub = parseInt(ipsub[i]);
if ((isNaN(sub)) || (sub <0) || (sub >255)) {
valid = false;
}
}

alert (valid);
</script>


"Very unusually it has turned noon here in Newcastle." - Football Commenator

phantom007
02-16-2009, 01:54 PM
That does not validate 192.168.0.1

It says invalid IP

Philip M
02-16-2009, 04:32 PM
That does not validate 192.168.0.1
It says invalid IP

Well, it returns true (= valid) for me.

phantom007
02-16-2009, 04:34 PM
Oh Yes you are right. I was missing something....

Thanx so much for your kind help :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum