PDA

View Full Version : IP Address Validation



rk0747
10th June 2010, 07:11
hi ,
I am facing problem with IP Address validation.

I wrote the condition like this , this is not working properly what i need.

Code:

QRegExp cpu1add2regExp( "((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){3}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])" );
lecpu1add2->setValidator(new QRegExpValidator(cpu1add2regExp, this));



1) 000.000.000.000 --to -- 999.999.999.999 // should allow only integers from( 0.1.2.3.4....9) and dot(.)

2) 112.543.432.33

x=122 // After x(3 digits one dot(.) should come) and don't allow fourth digit.
y=543
z=432
v=33 // v should be

Please anybody help me how to write the logic to get the required IP Address. i searched in forum also but didn't find.


Thanks & Regards

tbscope
10th June 2010, 07:25
112.543.432.33
I guess you do understand that this is not a valid IP address?


to get the required IP Address.
What is a required IP address?

Do you want to check if an IP address is valid?

rk0747
10th June 2010, 07:58
I guess you do understand that this is not a valid IP address?


What is a required IP address?

Do you want to check if an IP address is valid?


sir ,
i mean validation for lineEdit control when i want to enter the IP Address into lineEdit controll, that control should be allow only IP address . don't allow any alphabets ,characters except dot(.)

IP Address contain four parts and must three dots(.):
first part should contain 3 digits.(must)
second part should contain min 1 digit and max 3 digits..
third part should contain min 1 digit and max 3 digits.
four part should contain minimun 1 digit.


ex: 122.234.443.441
421.412.112.44
255.255.336.632
133.331.123.2
255.0.0.0
121.0.0.23




Below ADDRESS should not accept: should give error

ex: 24.253.321.422
23535.35.353.33
3532.333.332

squidge
10th June 2010, 09:02
What is this for? Is it for a network you are creating? As it's certain not valid for IPv4, which typically is what people mean by 'IP Address'.

rk0747
10th June 2010, 09:07
yes, use for ethernet . my lineEdit control should accept only IP Addresses(format).

sorry, i have to say lineEdit validation not IP validation.

squidge
10th June 2010, 09:18
The standard for ethernet is IPv4