carlosAlberto
IS-IT--Management
Hi all,
I have a piece of code that checks if a value entered is a valid IP address. I split the address into four part, which each part should be from 1 - 254.
This is the code where i actually check the value:
if (thisSegment < "0" || thisSegment > "254"
{
I have an alert box before this line and checked the value.
The problem arises when i enter 3.3.3.3 4.4.4.4 ... up to 9.9.9.9 all other value are check correctly.
The alert box shows thisSegment holds the value 3. This loops through 4 times. If i remove the OR statement it seems to work (just checking greater then 0).
Puzzled....
Is there something wrong with the above.
I have a piece of code that checks if a value entered is a valid IP address. I split the address into four part, which each part should be from 1 - 254.
This is the code where i actually check the value:
if (thisSegment < "0" || thisSegment > "254"
I have an alert box before this line and checked the value.
The problem arises when i enter 3.3.3.3 4.4.4.4 ... up to 9.9.9.9 all other value are check correctly.
The alert box shows thisSegment holds the value 3. This loops through 4 times. If i remove the OR statement it seems to work (just checking greater then 0).
Puzzled....
Is there something wrong with the above.