Tag: jquery globalization

使用.Net MVC Project上的本地号码全球化错误

我试图validation本地十进制数字(葡萄牙语 – > pt-PT),但我在浏览器中收到控制台错误: Uncaught TypeError: t.parseFloat is not a function. Exception occurred when checking element SizeOpenedWidth, check the ‘number’ method. 在葡萄牙,小数点分隔符是“,”,因此这里的有效十进制数是“10,21”。 我用来加载全球化的脚本: $.when( $.getJSON(“/Scripts/cldr/supplemental/likelySubtags.json”), $.getJSON(“/Scripts/cldr/main/numbers.json”), $.getJSON(“/Scripts/cldr/main/ca-gregorian.json”), $.getJSON(“/Scripts/cldr/supplemental/timeData.json”) ).then(function () { // Normalize $.get results, we only need the JSON, not the request statuses. return [].slice.apply( arguments, [ 0 ] ).map(function( result ) { return […]

en-GB日期不显眼的validation

我正在使用asp.net MVC4设计一个数据输入表单,它有一个类型为date的输入。 在chrome和jQueryUI datepicker中使用不显眼的jQuery库我仍然收到错误(字段news_date必须是日期。),在选择正确的日期格式后,使用datepicker(即14/02/2013)并提交表单。 一些搜索建议我应该使用jQuery.globilization库。 因此,在阅读文档后,我添加了对以下脚本的引用。 $(document).ready(function () { $.culture = Globalize.culture(“en-GB”); $.validator.methods.date = function (value, element) { return this.optional(element) || Globalize.parseDate(value, “dd/MM/yyyy”, “en-GB”); } }); 但是我仍然得到错误 如果我在chrome中调试上面的代码我可以看到“value”的值是“2014-02-14”。 下面是渲染的html。 $(function () { $(“.datepicker”).datepicker({ dateFormat: “dd/MM/yyyy” }); }); The field news_date must be a date. 更新 :顺便提一下,如果我将validation器方法更改为硬编码。 即 $.validator.methods.date = function (value, element) { return this.optional(element) […]