示例#1
0
 private void TxtEmailId_Validating(object sender, CancelEventArgs e)
 {
     if (string.IsNullOrEmpty(TxtEmailId.Text))
     {
         MessageBox.Show("User EmailId Cannot Left Blank...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
         e.Cancel = true;
         TxtEmailId.Focus();
         return;
     }
 }
示例#2
0
 private void TxtEmailId_Validating(object sender, CancelEventArgs e)
 {
     if (_Tag == "" || this.ActiveControl == TxtEmailId)
     {
         return;
     }
     if (string.IsNullOrEmpty(TxtEmailId.Text))
     {
         MessageBox.Show("Email Id Cannot Left Blank...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
         e.Cancel = true;
         TxtEmailId.Focus();
         return;
     }
     else if (_Tag == "NEW")
     {
         if (_objUserMaster.CheckDuplicateEmail(TxtEmailId.Text) == 1)
         {
             MessageBox.Show("Email Id Already Exist...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
             e.Cancel = true;
             TxtEmailId.Focus();
             return;
         }
         else
         {
             string email = TxtEmailId.Text;
             Regex  regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
             Match  match = regex.Match(email);
             if (!match.Success)
             {
                 MessageBox.Show(email + " is incorrect...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 e.Cancel = true;
                 TxtEmailId.Focus();
                 return;
             }
         }
     }
 }