Skip to content

Commit

Permalink
Validate datetime-local input
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Jan 27, 2025
1 parent c2bb929 commit fec14c6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/api/app/assets/javascripts/webui/content-selector-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@ function submitFilters() {

let submitFiltersTimeout;
$(document).on('change keyup', '#content-selector-filters-form input, #content-selector-filters-form select', function() {
highlightSelectedFilters();
// Clear the timeout to prevent the pending submission, if any
window.clearTimeout(submitFiltersTimeout);

// Validate datetime-local inputs
if ($(this).attr('type') === 'datetime-local') {
// Parse the value
const datetime = new Date($(this).val());
if (isNaN(datetime.getTime())) {
window.console.error("Invalid date or time format");
return;
}
}
highlightSelectedFilters();

// Set a timeout to submit the filters
submitFiltersTimeout = window.setTimeout(submitFilters, 2000);
});

Expand Down

0 comments on commit fec14c6

Please sign in to comment.