asp.net mvc - Date not being displayed properly when using jQuery mask -
i trying use this jquery plugin input mask on asp mvc edit
page. however, no matter value being stored in database, month displayed 2 zeros: 00/dd/yyyy
. i've stepped through code in visual studio , checked actual value stored in database , have verified correct.
here jquery view. of other input masks work on page. $('#birthdate')
1 in question.
$(document).ready(function ($) { $('#homephone').mask("(999) 999-9999? x99999"); $('#businessphone').mask("(999) 999-9999? x99999"); $('#mobilephone').mask("(999) 999-9999"); $('#faxnumber').mask("(999) 999-9999? x99999"); $('#birthdate').mask("99/99/9999"); $('#homezip').mask("99999?-9999"); $('#mailingzip').mask("99999?-9999"); $('#locationzip').mask("99999?-9999"); }); <div class="m-editor-field"> @html.editorfor(model => model.birthdate) </div> <div class="m-validator-field"> @html.validationmessagefor(model => model.birthdate) </div>
here jquery using on page.
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js" type="text/javascript"></script> <script src="http://cloud.github.com/downloads/digitalbush/jquery.maskedinput/jquery.maskedinput-1.3.min.js"></script>
edit
here field on model. have display set such
[displayname("date of birth")] [displayformat(dataformatstring = "{0:mm/dd/yyyy}", applyformatineditmode = true)] public datetime? birthdate { get; set; }
turned out issue w/the displayformat
's dataformatstring
. capitalizing month fixed problem :)
[displayname("date of birth")] [displayformat(dataformatstring = "{0:mm/dd/yyyy}", applyformatineditmode = true)] public datetime? birthdate { get; set; }
Comments
Post a Comment