Validate IP Address

Bubbly
Posted by Bubbly under Regular Expressions category on | Views : 3821
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 or Responses

Login to post response