Browse code

Remove costly realtime validation in check in

Benjamin Roth authored on01/09/2025 10:16:43
Showing1 changed files
... ...
@@ -297,8 +297,10 @@
297 297
                         }
298 298
                     }
299 299
 
300
-                    // Load available numbers immediately when the modal is opened
301
-                    loadAvailableNumbers();
300
+                    // Load available numbers immediately when the modal is opened (generate once)
301
+                    if (!numbersLoaded) {
302
+                        loadAvailableNumbers();
303
+                    }
302 304
 
303 305
                     // Function to load available numbers via Ajax
304 306
                     function loadAvailableNumbers() {
... ...
@@ -583,10 +585,8 @@
583 585
                         });
584 586
                     }
585 587
 
586
-                    // Add change event to all inputs
587
-                    $inputs.on('change', function() {
588
-                        updateDatalist();
589
-                    });
588
+                    // Remove dynamic datalist updates on change per requirements (datalist generated once at start)
589
+                    $inputs.off('change');
590 590
 
591 591
                     // Add focus event to all inputs to load numbers when first focused
592 592
                     $inputs.on('focus', function() {
... ...
@@ -595,43 +595,26 @@
595 595
                         }
596 596
                     });
597 597
 
598
-                    // Add input event to handle typing in the fields
598
+                    // Input event: no realtime validation and no dynamic datalist updates; only clear any previous validation state when user types
599 599
                     $inputs.on('input', function() {
600
-                        // Update the datalist when the user types in the field
601
-                        // Use a small delay to avoid too frequent updates
602
-                        clearTimeout($(this).data('inputTimer'));
603
-                        $(this).data('inputTimer', setTimeout(updateDatalist, 300));
604
-
605
-                        // Only remove validation classes and messages if this is not a server-side error
606
-                        // or if the user has changed the value
607 600
                         var $input = $(this);
608 601
                         var inputId = $input.attr('id');
609 602
                         var initialValue = $input.data('initial-value');
610 603
                         var currentValue = $input.val();
611 604
 
612
-                        // Store initial value on first input
613 605
                         if (initialValue === undefined) {
614 606
                             $input.data('initial-value', currentValue);
615 607
                             initialValue = currentValue;
616 608
                         }
617 609
 
618
-                        // If value has changed from initial value, remove validation classes
619 610
                         if (currentValue !== initialValue) {
620 611
                             $input.removeClass('is-valid is-invalid');
621 612
                             $('#' + inputId + '-validation').remove();
622 613
                         }
623 614
                     });
624 615
 
625
-                    // Add blur event to validate when field loses focus
626
-                    $inputs.on('blur', function() {
627
-                        var $input = $(this);
628
-                        var value = $input.val().trim();
629
-
630
-                        // Only validate if the field has a value
631
-                        if (value) {
632
-                            validateInput($input);
633
-                        }
634
-                    });
616
+                    // Remove realtime validation: no validation on blur anymore per requirements
617
+                    $inputs.off('blur');
635 618
 
636 619
                     // Add form submit handler to validate all fields before submission
637 620
                     $form.on('submit', function(e) {