This is a migrated thread and some comments may be shown as answers.

kendo validator does not support ASP MVC EmailAddressAttribute

1 Answer 528 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 28 Oct 2012, 10:49 PM
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.

Thanks





1 Answer, 1 is accepted

Sort by
0
Shiva
Top achievements
Rank 1
answered on 16 Mar 2013, 05:55 PM
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.

Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Shiva
Top achievements
Rank 1
Share this question
or