title: MaxLength(data annotation) - Not working when used after trimming the string entered in the text box
body: <p>I have a textbox which accepts 4 alphanumeric characters and spaces. 
  For ex: <code>34 56</code> should be valid
  <code>6789</code> is also valid.</p>
  
  <pre><code>$('#empIdtextbox1').on('blur', function () {
      var val = $(this).val();
      $(this).val(val.replace(" ", ''));
  });
  </code></pre>
  
  <p>and </p>
  
  <pre><code>[MaxLength(4, ErrorMessage = "The emp code cannot be more than 4 alphanumeric characters")]
  </code></pre>
  
  <p><code>public string EmpId{ get; set; }</code></p>
  
  <p>However when I type <code>34 56</code>, It replaces the spaces but displays <code>The emp code cannot be more than 4 alphanumeric characters.</code></p>
  
  <p>Any input on this will be helpful</p>