Dmitrij Solov

Dmitrij Solov

  • NA
  • 43
  • 6.6k

masked textbox validation

Oct 29 2016 3:35 PM
Hello, I used to work on the following subject for 3 days.
 
I have a masked textbox event:
 

  1. private void button4_Click(object sender, EventArgs e)  
  2. {  
  3.       maskedTextBox1.Mask = "999-000-0000";  
  4. }  
  5.    
  6. //and the validation of this event:  
  7.    
  8. private void button5_Validating(object sender, CancelEventArgs e)  
  9. {  
  10.       string text = this.Password //string value  
  11.       string pat = @"^9994714711" //code to match  
  12.       Regex itsme = new Regex(pat, RegexOptions.IgnoreCase);  
  13.       Match itsme2 = itsme.Match(text);  
  14.       if (itsme2.Success) { }  
  15.       else  
  16.        {  
  17.               MessageBox.Show("Something wrong happend, no match""Error");  
  18.               e.Cancel = true;  
  19.         }  

 
I recieve allways Error-Messages
Can somebody help me?

Answers (6)