kendo validator does not support ASP MVC EmailAddressAttribute

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Sep 2012

    Posted 28 Oct 2012 Link to this post

    I have an ASP MVC 4, .Net 4.5 project.  I am using the new EmailAddressAttribute validation data annotation attribute on my view models to validate a correct email format is posted.

    The attribute is correctly rendered on the input element as <input type="text" ... data-val-email="Email address format is incorrect" .../>.

    If I use the kendo validator to validate my form before post to server, the email rule seems to be ignored.  I believe I have included all the necessary js files to support unobstrusive validation.  All my other data annotation rules are applied correctly.

    When I look at kendo.aspnetmvc.min.js, it appears as though the kendo "email" rule is never mapped to the data-val-email rule pattern?

    If I write my input element from scratch <input type="email" required .../> obviously my email rule is applied correctly by the kendo validator.  This is not an ideal solution though because I am trying to standardise on using the data annotation attributes for my view models.

    Can you please tell me if I have done something wrong?  I rechecked the 2012 q3 beta and it appears to have the same limitation.


  2. Shiva
    Shiva avatar
    2 posts
    Member since:
    Dec 2012

    Posted 16 Mar 2013 Link to this post

    Use following syntax

    @Html.TextBoxFor(m => m.ContactDetail.Email, new { placeholder = "Email", type = "email", @class = "k-textbox required" })

    Note that type is defined as HTMLAttributes which will override defult type=text and you will get desired result.

Back to Top