Date object in meteor and autoforms

I have a problem entering the date of the validation date on Meteor, AutoForm and Simple-schema.

If you enable automatic date selection in Chrome, the check cannot recognize the date format or a type similar to the scheme ( type: Date ) or from the input ( type = "date" ) "08/19/2014"

If you turn off Chrome date picker, and when I use bootstrap3-datepicker and with js moment , set the format to "2014-08-19" as they wrote, I have the same date check problem.

  • What date format can be checked correctly in a scheme with type : Date ?
  • Which date choice is best to give me the correct format and type of date, and could you give me an example, because in metotrape form I saw the same problem.

Example:

.js

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

.html

{{> afQuickField name = "orderDate" type = "date"}}

or with {{#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> 

or with bootstrap3-datepicker

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

Thanks.

+6
source share
2 answers

The date format is a combination of 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. 

You can point this format to data-date-format , but it is best to add the format to the schema:

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

For example, dd M yyyy gives you 27 Apr 2017 .

I found the documentation at http://bootstrap-datepicker.readthedocs.io/en/latest/options.html

+1
source

Just by looking at the documentation for the original bootstrap-datepicker, I think the aldeed package just wraps around, I think you need something like:

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

or

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

Specify the date format you want with the data-date-format attribute.

0
source

Source: https://habr.com/ru/post/974050/


All Articles