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

查看:122
本文介绍了如何使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将显示15Aoû,2012,正如我期望的那样.但是,我的问题是,发布表单时,DatePicker的值发布为"15Aoû,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?

我意识到我可以将dateformat更改为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天全站免登陆