Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange MVC 4 validation behaviour when using DataType.EmailAddress
    primarykey
    data
    text
    <p>I am using unobtrusive javascript and data annotations for my validation, and it works fine. I decided to decorate my view model properties with DataType attributes. For the most part this to is fine, with the exception of DataType.EmailAddress</p> <p>When I add this attribute, I suddenly get extra validation on this field, that renders a call out on the field, a bit like the validation call out in the Ajax Control toolkit. Only the style is different with a thick red boarder to the element being validated, and the callout is below. The call out also displays a message not specified in my view model. The regex I have for validation has an error message of “The email address you have entered is invalid” whereas the message in the callout is “You must enter a valid email address”. I have tried searching my solution for this text and it is not found. Finally the only scripts I have loaded are:</p> <pre><code>&lt;script src="/Public/javascript/jquery-1.9.1.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/jquery-migrate-1.0.0.js"&gt;&lt;/script&gt; &lt;script src="/Public/javascript/jquery.unobtrusive-ajax.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/Public/javascript/jquery.validate.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/Public/javascript/jquery.validate.unobtrusive.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>And css:</p> <pre><code>&lt;link href="/Public/themes/ui-darkness/jquery-ui-1.9.2.custom.min.css" rel="stylesheet" type="text/css" /&gt; &lt;link href="/Content/PagedList.css" rel="stylesheet" type="text/css" /&gt; &lt;link href="/Public/css/reset.css" rel="stylesheet" type="text/css" /&gt; </code></pre> <p>I am also using @Html.EditorFor to render all my fields throughout my view.</p> <p>Can anyone shed any light on what is happening? Where is this callout coming from? Can I disable it? Can I use it and have it on the rest of my fields? Should I just remove DataType.EmailAddress? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload