开发者

Is it possible to specify the display format for a dijit.form.DateTextBox

开发者 https://www.devze.com 2023-03-03 12:28 出处:网络
Is it possible to specify the display format for a dijit.form.DateTextBox? I know that dij开发者_开发问答it.form.DateTextBox gets its date format from the user\'s locale by default and I know I can s

Is it possible to specify the display format for a dijit.form.DateTextBox?

I know that dij开发者_开发问答it.form.DateTextBox gets its date format from the user's locale by default and I know I can swtich the locale to anything I want, but I need to just specify the date format and not change anything else. Is this possible?

Thanks.


Yes, you can do something like this:

var occursOnField = new dijit.form.DateTextBox({
    constraints: { datePattern : 'yyyy-MM-dd' }
    , promptMessage: "yyyy-MM-dd"
    , invalidMessage: "Invalid date format. Use yyyy-MM-dd"
})

Update Jan 29, 2012:

Chrome and Dojo 1.6.1 compatibility bug.

If the day of month is being padded with too many 0s, use one less d in the date pattern to work around the bug. For example, on Google Chrome 16 and Dojo 1.6.1 : datePattern : 'yyyy-MM-dd' will give 2010-01-001 and datePattern : 'yyyy-MM-d' will give 2010-01-1.


try this simple thing:

    <input type="text"  name="Date"  id="myDate" promptMessage="Please Enter Date" value="" data-dojo-type="dijit/form/DateTextBox" constraints="{datePattern:'dd-MMM-yyyy', strict:true}"  />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号