6 September 2013

Validate 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";
    }
}

No comments:

Post a Comment