title: Limiting length of a phone number
body: <p>I want a field for a phone number to take in a maximum of 10 digits. I have the [stringlength] attribute placed but I still cannot get the desired result. Thanks to those that can help me.</p>
  
  <p>On a side note, is it possible to break apart the phone number so that the area code and the remaining digits get sent out separately to a db via a stored proc?</p>
  
  <p>model:</p>
  
  <pre><code> public class Pharmacy
  {
    [StringLength(10,MinimumLength=10)]
      public string PhoneNumber
      {
          get
          {
              return _phoneNumber;
          }
          set
          {
              Regex regexObj = new Regex(@"[^\d]");
              _phoneNumber = regexObj.Replace(value, "");
              _phoneNumber = Regex.Replace(_phoneNumber, @"(\d{3})(\d{3})(\d{4})", "($1) $2-$3");
          }
      }
  }
  </code></pre>
  
  <p>form field:</p>
  
  <pre><code> &lt;label id="lblPhoneNumber"&gt;Phone Number&lt;/label&gt;                       
   &lt;input style="margin: 5px; " type=text name="txtPhoneNumber" id="txtPhoneNumber" value="@Model.Pharmacy.PhoneNumber" /&gt;  
  </code></pre>