Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery.validate.unobtrusive: compare attribute is always failing
    text
    copied!<p>I have two email fields on a form to validate that the user entered his email properly. However, jquery.validate.unobtrusive always shows an error message even when the email is entered twice correctly.</p> <p>This is an ASP.Net MVC 3 project, and I am using the Compare Attribute on the second email field.</p> <p>Here is the html code of that region on my web page:</p> <pre><code>&lt;div class="editor-field"&gt; &lt;input class="text-box single-line" data-val="true" data-val-length="The field Adresse de courriel must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="L&amp;amp;#39;adresse de courriel doit &amp;amp;#234;tre sp&amp;amp;#233;cifi&amp;amp;#233;e" id="Requerant_Individu_Courriel" name="Requerant.Individu.Courriel" type="text" value="" /&gt; &lt;span class="field-validation-valid" data-valmsg-for="Requerant.Individu.Courriel" data-valmsg-replace="true"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;input class="text-box single-line" data-val="true" data-val-equalto="Les deux adresses de courriel doivent &amp;amp;#234;tre identiques" data-val-equalto-other="*.Courriel" data-val-required="L&amp;amp;#39;adresse courriel de confirmation doit &amp;amp;#234;tre sp&amp;amp;#233;cifi&amp;amp;#233;e" id="Requerant_Individu_ConfirmCourriel" name="Requerant.Individu.ConfirmCourriel" type="text" value="" /&gt; &lt;span class="field-validation-valid" data-valmsg-for="Requerant.Individu.ConfirmCourriel" data-valmsg-replace="true"&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>I noticed this attribute on the second email input: data-val-equalto-other="*.Courriel" I am wondering whether that asterisk is correct.</p> <p>And here is what I have in my model:</p> <pre><code> [Required(ErrorMessage = "L'adresse de courriel doit être spécifiée")] [StringLength(50)] [Display(Name = "Adresse de courriel")] public String Courriel { get; set; } [Compare("Courriel", ErrorMessage = "Les deux adresses de courriel doivent être identiques")] [Required(ErrorMessage = "L'adresse courriel de confirmation doit être spécifiée")] [Display(Name = "Retapez votre adresse de courriel")] public string ConfirmCourriel { get; set; } </code></pre> <p>Anyone has ever encountered that problem? Suggestions?</p> <p>Note: I am using jQuery 1.6.3 and jQuery Validation Plugin 1.8.1</p>
 

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