Use this regex:
^\d+([,]\d+)*$
bool valid = System.Text.RegularExpressions.Regex.IsMatch("1,21,31,456", @"^\d+([,]\d+)*$");
bool valid = System.Text.RegularExpressions.Regex.IsMatch("1,21", @"^\d+([,]\d+)*$");
valid = System.Text.RegularExpressions.Regex.IsMatch("1,21,31,456", @"^\d+([,]\d+)*$");