Validate an IP address

An example of validating an IP address


using System.Text.RegularExpressions;

public class IPAddressTextBox: RegExTextBox
{
public IPAddressTextBox()
{
InitializeComponent();
this.ValidationExpression = @"^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$";
this.ErrorMessage = "The IP address must be in the form of 111.111.111.111";
}


Comments

Author: Sathish KUmar.L26 Feb 2009 Member Level: Silver   Points : 1

Function for validate IPAddress


Function IsValidIP(ByVal ipAddress As String) As Boolean
Return System.Text.RegularExpressions.Regex.IsMatch(ipAddress, _
"^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$")
End Function

Author: Deepika Haridas08 Jun 2009 Member Level: Gold   Points : 1

Hi Sathish,

Thanks for sharing that code too..

Keep sharing

Regards,
Deepika

Author: Sachin09 Jun 2009 Member Level: Gold   Points : 0

Usefull post..
Thanks ..

Author: Deepika Haridas28 Feb 2010 Member Level: Gold   Points : 1

Hello Sachin,

Thanks

--
Thanks & Regards,
Deepika



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: