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 73e54bf commit 0556304
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ function submitFilters() {

let submitFiltersTimeout;
$(document).on('change keyup', '#content-selector-filters-form input, #content-selector-filters-form select', function() {
if ($(this).attr('type') == 'datetime-local') {
// Parse the value
const datetime = new Date($(this).val());
if (isNaN(datetime.getTime())) {
console.error("Invalid date or time format");
return;
}
}
highlightSelectedFilters();
window.clearTimeout(submitFiltersTimeout);
submitFiltersTimeout = window.setTimeout(submitFilters, 2000);
Expand Down

0 comments on commit 0556304

Please sign in to comment.