The following function will ensure the zip code in the following format
12345 or 54321-1234
public bool IsZipCode(string zipCode) { string pattern = @"^\d{5}(\-\d{4})?$"; Regex regex = new Regex(pattern); return regex.IsMatch(zipCode); }
The following function will ensure the zip code in the following format
12345 or 54321-1234
public bool IsZipCode(string zipCode) { string pattern = @"^\d{5}(\-\d{4})?$"; Regex regex = new Regex(pattern); return regex.IsMatch(zipCode); }