Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Date Picker value does not submit value with Form

waynefulcher pro asked 6 years ago


I am using the most basic example of the Datepicker inside a <form> element.
<div class="md-form" style="max-width: 200px;">
<input type="text" id="cycle-end-date" class="form-control datepicker">
<label for="cycle-end-date">Cycle End Date</label>
</div>
I initialize it as follows:
$(document).ready(function () {
$('.datepicker').pickadate({
format: 'mm-dd-yyyy',
});
}


Then I am overriding the form submit with jquery/ajax as follows:

$('#report-upload-form').submit(function(e) {
    e.preventDefault();

    var form = $(this);
    var data = new FormData(this);
    var url = form.attr( "action");
    var method = form.attr( "method" );
    var msg = 'Uploading report...'
    $('#cover-screen-text').text(msg);
    $('#cover-screen').show();

    $.ajax({
        url         : url,
        data        : data,
        cache       : false,
        contentType : false,
        processData : false,
        type        : method,
        dataType    : 'json'
    })
    .always(function () {
        $('#cover-screen').hide();
    })
    .done(function (data) {
        // occurs only on success
        if (data.success) {
            showMessage('Success', data.msg);
        }
        else
            showError('Error', data.error);
    })

    ;
});
On the server I display all inputs from the request and it has everything except for the datepicker field/value. Any help would be greatly appreciated. Thanks

Piotr Glejzer staff commented 6 years ago

Do you have any errors on debugger?

Jakub Mandra staff answered 6 years ago


Hello, It seams that DatePicker doesn't set the value to the input. It is something which needs deeper investigation. I send the ticket to JQuery team.   Regards, Jakub

jouvrard pro answered 6 years ago


I can see your input hasn't a name="my_name" tag. Normal?

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.5.9
  • Device: any
  • Browser: Chrome 68 64bit
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No