Google Chrome中的Datepicker UI格式错误 [英] Datepicker UI format error in Google Chrome
问题描述
我使用Jquery UI datepicker进行了一些测试,发现日期格式与Chrome不能正常工作 - 如果我输入13/10/2009,则会出现错误的格式。我认为发生的是格式是所有浏览器和验证的dd / mm / yyyy,但由于某些原因,chrome默认为mm / dd / yyyy - 即它在所有其他浏览器而不是谷歌浏览器中工作正常。
I have been doing some testing whilst using Jquery UI datepicker and have found that the date format doesn't work correctly with Chrome - if I type 13/10/2009 an error appears saying that it is incorrect format. What I think has happened is that the format is dd/mm/yyyy for all browsers and validation but for some reason chrome has defaulted to mm/dd/yyyy - i.e. it works fine across all other browsers but not Google Chrome.
这里有一个链接: https://www.carcreditassured.co.uk/apply-now-poor-rating/ (在这种情况下,我将将问题类型更改为三个选择框以帮助可用性,但我想知道答案供将来参考)
Here's a link: https://www.carcreditassured.co.uk/apply-now-poor-rating/ (on this occassion I'm going to change the question type to three select boxes to aid usability but I would like to know an answer for future reference)
这是我的jquery代码:
Here's my jquery code:
$('.date-pick').datepicker({
showOn: 'both',
buttonText: 'Choose a date',
buttonImage: '/images/calendar.png',
buttonImageOnly: true,
dateFormat: 'dd/mm/yy',
numberOfMonths: 1,
showButtonPanel: true
});
任何建议将不胜感激。
最好的祝福
Rachel
Any advice would be greatly appreciated. Best wishes Rachel
在这个论坛上阅读了另一篇文章后,我尝试了MM,并提供了一个格式(2009年10月13日),这不是我正在寻找的。
P.S. After reading another post on this forum I tried to captialise the MM and that gives a format of (13 October 2009) which isn't what i'm looking for.
推荐答案
我认为浏览器的区域设置设置(适用于谷歌,转到chrome:/ / settings / language)
I think it looks at the browser's Locale settings (for google, go to chrome://settings/language)
您需要将其设置为您的选择器控件,如下所示:
You'll need to set it for your picker control like so:
$('.date-pick').datepicker("option", $.datepicker.regional["en-GB"]);
表示,您的选择器将以dd / mm / yyyy格式生成日期,即使我设置谷歌浏览器使用美式英语,虽然周从星期天开始,但它仍然受到影响,除非您按照我提供的代码设置控件的文化。
having said that, your picker results in dates in dd/mm/yyyy format for me even if I set Google Chrome to use American English, albeit the week starts with Sunday, so it's still influenced unless you set control's culture as per code I've provided.
这篇关于Google Chrome中的Datepicker UI格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!