示例#1
0
 private void text_phone_Validating(object sender, CancelEventArgs e)
 {
     if (string.IsNullOrEmpty(text_phone.Text.Trim()) || !Regex.Match(text_phone.Text, @"^(0[0-9]{9})$").Success)
     {
         e.Cancel = true;
         text_phone.Focus();
         ErrorEmpty.SetError(text_phone, "Bạn phải nhập đúng định dạng số điện thoại (10 số).");
     }
     else
     {
         e.Cancel = false;
         ErrorEmpty.SetError(text_phone, null);
     }
 }
示例#2
0
 private void text_email_Validating(object sender, CancelEventArgs e)
 {
     if (string.IsNullOrEmpty(text_email.Text.Trim()) || !text_email.Text.Contains("@") || !text_email.Text.Contains("."))
     {
         e.Cancel = true;
         text_email.Focus();
         ErrorEmpty.SetError(text_email, "Bạn phải nhập đúng định dạng email.");
     }
     else
     {
         e.Cancel = false;
         ErrorEmpty.SetError(text_email, null);
     }
 }
示例#3
0
 private void checkErrorEmpty(TextBox textBox, string message, CancelEventArgs e)
 {
     if (string.IsNullOrEmpty(textBox.Text.Trim()))
     {
         e.Cancel = true;
         textBox.Focus();
         ErrorEmpty.SetError(textBox, message);
     }
     else
     {
         e.Cancel = false;
         ErrorEmpty.SetError(textBox, null);
     }
 }