Date format when editing results in "Input not Valid"

Date format when editing results in "Input not Valid"

Ed MartinEd Martin Posts: 23Questions: 5Answers: 0

I am running into a validation error when using the datepicker on the edit form. I have tried to change the date format the form accepts, but I continue to get ddd D mmm YY.

I have changed the format in the js code, but my changes are not showing up in the edit form. Is there another place to change these settings?

This question has an accepted answers - jump to answer

Answers

  • Ed MartinEd Martin Posts: 23Questions: 5Answers: 0
    edited June 2020
    /*
     * Editor client script for DB table delivery
     * Created by http://editor.datatables.net/generator
     */
    
    (function($){
    
    $(document).ready(function() {
        var editor = new $.fn.dataTable.Editor( {
            ajax: 'php/table.delivery.php?format=custom',
            table: '#delivery',
            fields: [
                {
                    "label": "quantity:",
                    "name": "delivery.quantity"
                },
                {
                    "label": "price:",
                    "name": "delivery.price",
                    
                },
                {
                    "label": "Delivery Date:",
                    "name": "delivery.orderdate",
                    type:       'date',
                    def:        function () { return new Date(); },
                    dateFormat: 'm/d/yy'
                }
            ]
        } );
    
        var table = $('#delivery').DataTable( {
            ajax: 'php/table.delivery.php',
            columns: [
                {
                    "data": "delivery.orderid"
                },
                {
                    "data": "delivery.quantity"
                },
                {
                    "data": "delivery.product"
                },
                {
                    "data": "delivery.cropid"
                },
                {
                    "data": "delivery.price",
                    render: $.fn.dataTable.render.number( ',', '.', 2, '$' )
                },
                {
                    "data": "customers.customerCoName"
                },
                {
                    "data": "delivery.orderdate"
                }
            ],
            select: true,
            lengthChange: false
        } );
    
        new $.fn.dataTable.Buttons( table, [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor }
        ] );
    
        table.buttons().container()
            .appendTo( $('.col-md-6:eq(0)', table.table().container() ) );
    } );
    
    }(jQuery));
    
  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    I would recommend using datetime, rather than date. As it says on the reference page:

    Please note that as of Editor 1.5.2 the new datetime field type is preferred over this option as it provides a date and/or time picker built into Editor, that works cross platform.

    There you have displayFormat and wireFormat so you have more control on the format to use.

    Colin

This discussion has been closed.