繁体   English   中英

流星和autoform中的日期对象

[英]Date object in meteor and autoform

我在Meteor,AutoForm和Simple-schema上输入日期验证有问题。

如果启用Chrome自动日期选择器,则验证无法识别日期格式或类型,如架构( 类型:日期 )或输入( 类型=“日期” )“08/19/2014”

如果它关闭了Chrome日期选择器,当我使用bootstrap3-datepicker并且将js设置格式设置为“2014-08-19”时就像他们写的一样,我有相同的日期验证问题。

  1. 类型为:Date的模式中可以正确验证哪种日期格式?
  2. 哪个日期选择器最好给我正确的日期格式和类型,你能不能给我一个例子,因为在meteor-autoform-example中我看到了同样的问题。

例:

.js文件

schema: {
    'orderDate': {
        type: Date,
        label: "OrderDate",
        optional: true
        }

html的

{{> afQuickField name =“orderDate”type =“date”}}

或者使用{{#autoForm}}

<div class="form-group {{#if afFieldIsInvalid name='orderDate'}}has-error{{/if}}">
  {{> afFieldLabel name='orderDate'}}
  <span class="help-block">*Requered</span>
  {{> afFieldInput name='orderDate' id="OrderDate"}}
  {{#if afFieldIsInvalid name='orderDate'}}
<span class="help-block">{{{afFieldMessage name='orderDate'}}}</span>
{{/if}}
</div>

或者使用bootstrap3-datepicker

<input type="date" id="orderPickerDate" class="form-control" />

谢谢。

日期格式是d,dd,D,DD,m,mm,M,MM,yy,yyyy的组合。

d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05.
D, DD: Abbreviated and full weekday names, respectively. Eg, Mon, Monday.
m, mm: Numeric month, no leading zero and leading zero, respectively. Eg, 7, 07.
M, MM: Abbreviated and full month names, respectively. Eg, Jan, January
yy, yyyy: 2- and 4-digit years, respectively. Eg, 12, 2012.

您可以在data-date-format format上指定此格式,但在架构中添加格式的更好位置:

some_date: {
    type: Date,
    autoform: {
      type: "bootstrap-datepicker",
      datePickerOptions: {
        autoclose: true,
        format: 'dd M yyyy'
      }
    }
  },

例如, dd M yyyy给你27 Apr 2017

我在http://bootstrap-datepicker.readthedocs.io/en/latest/options.html找到了这些文档。

只是看看我认为aldeed的包刚刚包装的原始bootstrap-datepicker的文档,我想你想要的东西如下:

{{> afQuickField name='orderDate' type="bootstrap-datepicker" data-date-format="dd MM yyyy"}}

要么

{{> afFieldInput name='orderDate' type="bootstrap-datepicker" data-date-format="dd MM yyyy"}}

使用data-date-format属性指定所需的日期格式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM