title: user-input validation by reg exp on WPF textbox
body: <p>I have an array of input validations.
  Each row of the array represents a single input validation; a string of the regular expression check and a string to display for the user in case the validation went bad:</p>
  
  <pre><code>public class myClass
  {
       public static string[][] inputsInfo = new string[4][];
  
       static myClass()
       {
       // ID - 9 digits
       inputsInfo[0] = new string[2] { "^[0-9]{9}$", "exactly 9 digits (0-9)" };
  
       // only letters and possibly more than one word
       inputsInfo[1] = new string[2] { "^[A-Za-z]{2,}(( )[A-Za-z]{2,})*$", "only letters (A-Z) or (a-z)" };
  
       // Number - unlimited digits
       inputsInfo[2] = new string[2] { "^[0-9]+$", "only digits (0-9)" };
  
       // username, password
       inputsInfo[3] = new string[2] { "^[A-Za-z0-9]{6,}$", "at least 6 characters.\nOnly letters (A-Z) or (a-z) and digits (0-9) are allowed" };
  
       }
  ..............
  ..............
  }
  </code></pre>
  
  <p>I have windows which contain WPF textboxes. There are fields which have the same input validation, and that's why i want to save all the input validations in the array, so i can just select the validation i need at the moment.</p>
  
  <p>I have this form:</p>
  
  <pre><code>...............
  
          &lt;TextBlock Grid.Row="2" Grid.Column="0" Text="First name"/&gt;
          &lt;TextBox x:Name="firstName" Grid.Row="2" Grid.Column="1"/&gt;
          &lt;Button Grid.Row="2" Grid.Column="2" Content="Search"/&gt;
  
          &lt;TextBlock Grid.Row="3" Grid.Column="0" Text="Last name"/&gt;
          &lt;TextBox x:Name="lastName" Grid.Row="3" Grid.Column="1"/&gt;
          &lt;Button Grid.Row="3" Grid.Column="2" Content="Search"/&gt;
  
          &lt;TextBlock Grid.Row="4" Grid.Column="0" Text="ID number"/&gt;
          &lt;TextBox x:Name="ID" Grid.Row="4" Grid.Column="1"/&gt;
          &lt;Button Grid.Row="4" Grid.Column="2" Content="Search"/&gt;
  
  ...............
  </code></pre>
  
  <p>Each textbox has a near button with a Click event.
  How can i perform an input validation by a button click?</p>
  
  <p>Is there a way doing that by XAML code?
  or only in the code-behind by c# code?</p>
  
  <p>Any help will be appreciated.</p>