title: ASP.NET MVC4 Bootstrap modal validation
body: <p>I've an issue with validating user input in bootstrap modal before form submission.
  I have a class with this property</p>
  
  <pre><code>[FooValidation]
  [MaxLength(50)]
  [Required]
  public string Foo {get;set;}
  </code></pre>
  
  <p>the foo property has to be unique so that's why I created FooValidation attribute which looks like this:</p>
  
  <pre><code>public class FooValidationAttribute : ValidationAttribute
  {
      public override bool IsValid(object value)
      {
          //logic
           return true;
      }
  }
  </code></pre>
  
  <p>And in my view I have</p>
  
  <pre><code>@Html.TextBoxFor(model =&gt; model.Foo, new { @class = "form-control" })
  @Html.ValidationMessageFor(model =&gt; model.Foo)
  </code></pre>
  
  <p>Now the problem is, default attributes (Required and MaxLength) work just fine, when I try to submit the form I get the proper error messages, but my custom attribute doesn't, the IsValid method is called and returns proper value but the form gets submitted no matter what.
  Any idea what might be wrong?</p>
  
  <p>PS: I tried to override this method</p>
  
  <pre><code>ValidationResult IsValid(object value, ValidationContext validationContext)
  </code></pre>
  
  <p>as well but the result is the same.</p>