title: Validate float number using RegEx in C#
body: <p>I am trying to make a Numeric only <code>TextBox</code> in WPF and I have this code for it:</p>
  
  <pre><code>void NumericTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
  {
      e.Handled = !IsValidInput(e.Text);
  }
  
  private bool IsValidInput(string p)
  {
      switch (this.Type)
      {
          case NumericTextBoxType.Float:
              return Regex.Match(p, "^[0-9]*[.][0-9]*$").Success;
          case NumericTextBoxType.Integer:                    
          default:
              return Regex.Match(p, "^[0-9]*$").Success;                    
      }
  }
  
  // And also this!
  public enum NumericTextBoxType
  {
      Integer = 0, 
      Float = 1
  }
  </code></pre>
  
  <p>When I set the type to Integer, it works well, but for Float, it does not.  </p>
  
  <p>I can use so many <code>NumericTextBox</code> controls out there, but I was wondering why this one is not working?</p>