简体   繁体   中英

only submit server side request when date in date range is in valid format

I am using YADCF with date range filter. I am using the jQuery-ui datepicker type. Data is returned to the datatable from AJAX requests (serverSide is set in the datatables config).

This works fine as long as the user selects a valid date from the UI box. However, the user can also enter free text into the box (eg '20') and when this happens the server side raises an exception and returns error 400. This is ok but the ideal solution would be for the date format to be validated client-side, and the AJAX request is only sent when there is a valid date in the range box.

Is it possible to configure yadcf / datatables to only submit AJAX requests when there is a valid date?

yadcf.init(table, [
  {
    column_number: 0,
    filter_type: 'range_date',
    datepicker_type: 'jquery-ui',
    date_format: 'yyyy-mm-dd',
    filter_delay: 500,
    filter_container_id: 'timestamp_range_picker'
  }
]

在此处输入图像描述

You should probably fix this issue at the source, which is your input box. Set it as a date type and then there will be no chance of incorrect entry.

<input type="date" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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