如何使 jqueryUI datepicker 以与显示的格式不同的格式提交? [英] How to make jqueryUI datepicker submit in a different format than what is being displayed?

查看:27
本文介绍了如何使 jqueryUI datepicker 以与显示的格式不同的格式提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQueryUI 进行一些国际化.我的表单上有一个 DatePicker 控件,可以正常使用法语.

I'm working on some internationalization using jQueryUI. I have a DatePicker control on a form that is properly working in the French language.

当我选择一个日期时,例如 2012 年 8 月 15 日,DatePicker 将按我的预期显示 15 Aoû, 2012.然而,我的问题是,当表单发布时,DatePicker 的值被发布为15 Aoû, 2012",现在需要在服务器上进行翻译才能正确保存.

When I select a date, for example August 15, 2012, the DatePicker will display 15 Aoû, 2012 as I would expect. My issue however, is that when the form is posted, the value of the DatePicker is posted as '15 Aoû, 2012' which now needs to be translated on the server before it can be saved properly.

我的问题是,jQueryUI DatePicker 中是否有一种内置方式,以便我可以始终以一致的格式将其发布到服务器,而不管控件以哪种语言显示?如果没有内置方法,有哪些选择可以实现这一目标?

My question is, is there a built-in way inside the jQueryUI DatePicker so that I can have it always post to the server in a consistent format, regardless of which language the control is being displayed in? If there isn't a built-in way, what options exist for achieving this?

我意识到我可以将日期格式更改为 08/15/2012 之类的东西,而不是使用文本表示,但这不是我想要做的.

I realize that I can change the dateformat to something like 08/15/2012 instead of using the textual representation, however this isn't what I want to do.

推荐答案

有 2 个配置选项:altField 和 altFormat.http://api.jqueryui.com/datepicker/#option-altField如果您指定一个 altField,该字段也将被更新,并且将具有 altFormat.通常您会希望将 altField 设置为隐藏字段,因此您可以忽略常规字段并将 altField 发送到 db.

There's 2 configuration options for that: altField and altFormat. http://api.jqueryui.com/datepicker/#option-altField If you specify an altField, that field will be updated too, and will have the altFormat. Normally you will want make the altField a hidden field, soyou can ignore the regular field and send to db the altField.

这篇关于如何使 jqueryUI datepicker 以与显示的格式不同的格式提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆