asp.net mvc - Html.ValidationMessageFor not displaying at all -
asp.net mvc - Html.ValidationMessageFor not displaying at all -
i have next form:
<form action="~/buy-online" method="get" class="buy-online-form clearfix" autocomplete="off" id="buy-online-search"> <div class="infield-holder clearfix"> @html.labelfor(m => m.customerpostcode, new { @class = "infield" }) @html.textboxfor(m => m.customerpostcode, new { @class = "textbox" }) <input type="submit" value="buy online" id="find-retailer-button" class="button" /> </div> </form> @html.validationmessagefor(m => m.customerpostcode)
which works fine , display error message when submitted without jquery, when add together jquery validate scripts (v 1.11.1):
<script src="/scripts/jquery.validate.js"></script> <script src="/scripts/jquery.validate.unobtrusive.js"></script>
it stops form submitting doesn't display error message
my property marked so:
[displayname("enter total postcode")] [required(errormessage = "please come in total postcode")] public string customerpostcode { get; set; }
and html renders this:
<input class="textbox" data-val="true" data-val-required="please come in total postcode" id="customerpostcode" name="customerpostcode" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="customerpostcode" data-valmsg-replace="true"></span>
if inspect input when nail submit adding class input-validation-error
textbox not updating validation message.
all posts have checked on problem include scripts i'm @ loss why message not showing.
i've tried adding jquery.unobtrusive-ajax.js script didn't seem either. help appreciated, thanks.
you need include @html.validationmessagefor(m => m.customerpostcode)
within form tags jquery.validate.unobtrusive
work.
asp.net-mvc unobtrusive-validation
Comments
Post a Comment