Решил сделать категорию Does Not Work.
Все время забываю про это и наступаю на одни те же грабли.
Итак:
EntityFramework -
Does Not work
Все время забываю про это и наступаю на одни те же грабли.
Итак:
EntityFramework -
Does Not work
[Display(Name="Release Date")] [DataType(DataType.Date)]
public DateTime ReleaseDate { get; set; }Необходимо использовать
// [DataType(DataType.Date)] [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)] public DateTime ReleaseDate { get; set;
Does Not work: MVC jQuery Validation non-English locales
Note to support jQuery validation for non-English locales that use a comma (",") for a decimal point, and non US-English date formats, you must include globalize.js and your specificcultures/globalize.cultures.js file(from https://github.com/jquery/globalize ) and JavaScript to useGlobalize.parseFloat
. You can get the jQuery non-English validation from NuGet. (Don't install Globalize if you are using a English locale.)
http://msdn.microsoft.com/en-us/library/hy4kkhe0(v=vs.85).aspx
<system.web> <globalization culture ="en-US" /> <!--elements removed for clarity--> </system.web>
Or This
@section Scripts { @Scripts.Render("~/bundles/jqueryval") <script src="~/Scripts/jquery.globalize/globalize.js"></script> <script src="~/Scripts/jquery.globalize/cultures/globalize.culture.fr-FR.js"></script> <script> $.validator.methods.number = function (value, element) { return this.optional(element) || !isNaN(Globalize.parseFloat(value)); } $(document).ready(function () { Globalize.culture('fr-FR'); }); </script> <script> jQuery.extend(jQuery.validator.methods, { range: function (value, element, param) { //Use the Globalization plugin to parse the value var val = $.global.parseFloat(value); return this.optional(element) || ( val >= param[0] && val <= param[1]); } }); </script> <script> $.validator.methods.date = function (value, element) { return this.optional(element) || Globalize.parseDate(value); } </script> }you must include globalize.js and your specificcultures/globalize.cultures.js file(from https://github.com/jquery/globalize ) and JavaScript to use
Globalize.parseFloat
. You can get the jQuery non-English validation from NuGet. (Don't install Globalize if you are using a English locale.)
Комментариев нет:
Отправить комментарий