Web Design Forums - Cheap airsoft - Submit articles - Payday Loans - Wordpress Themes

PDA

View Full Version : jQuery IP Validator


cancer10
Feb 16th 2009, 3:42 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

dimitar christoff
Feb 16th 2009, 3:49 am
here's a simple regex to do it

var filter = /^(([1-9][0-9]{0,2})|0)\.(([1-9][0-9]{0,2})|0)\.(([1-9][0-9]{0,2})|0)\.(([1-9][0-9]{0,2})|0)$/;

cancer10
Feb 16th 2009, 5:49 am
EDIT: That does not validate 192.168.0.1

It says invalid IP

joebert
Feb 16th 2009, 10:23 pm
I don't think that jQuery plugin will work because of IP addresses having a variable length.

/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/

cancer10
Feb 16th 2009, 10:26 pm
oh ok.


Thanx for your help