@@ -412,20 +412,23 @@ document.addEventListener('DOMContentLoaded', function () {
412
412
document . getElementById ( "notifs-toggle" ) . addEventListener ( "change" , function ( e ) {
413
413
chrome . storage . local . set ( { notificationsEnabled : e . target . checked } ) ;
414
414
} ) ;
415
-
416
- document . getElementById ( 'policyName' ) . addEventListener ( 'input' , function ( e ) {
417
- if ( ! e . target . validity . valid ) {
418
- e . target . setCustomValidity ( "Policy names can only contain letters, apostrophes ('), numbers, spaces and ampersand symbols (&)." ) ;
419
- } else {
420
- e . target . setCustomValidity ( "" ) ;
421
- }
415
+
416
+ var policyInput = document . getElementById ( 'policyName' ) ;
417
+
418
+ policyInput . addEventListener ( 'invalid' , function ( event ) {
419
+ // Prevent the default browser tooltip
420
+ event . preventDefault ( ) ;
421
+ // Set custom validation message
422
+ this . setCustomValidity ( "Policy names cannot contain periods (.) or dollar signs ($)." ) ;
423
+ // Report the validity state with the custom error message
424
+ this . reportValidity ( ) ;
422
425
} ) ;
423
426
424
- document . getElementById ( 'policyName' ) . addEventListener ( 'invalid' , function ( e ) {
425
- if ( ! e . target . validity . valid ) {
426
- e . target . setCustomValidity ( "Policy names can only contain letters, apostrophes ('), numbers, spaces and ampersand symbols (&)." ) ;
427
- }
427
+ // Reset the custom validity message after the user starts modifying the input
428
+ policyInput . addEventListener ( 'input' , function ( ) {
429
+ this . setCustomValidity ( '' ) ;
428
430
} ) ;
431
+
429
432
430
433
const isFormOpen = localStorage . getItem ( 'isFormOpen' ) === 'true' ;
431
434
const formOpenTimestamp = parseInt ( localStorage . getItem ( 'formOpenTimestamp' ) || '0' ) ;
@@ -613,11 +616,6 @@ function logUserOut() {
613
616
} ) ;
614
617
}
615
618
616
-
617
-
618
-
619
-
620
-
621
619
chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
622
620
chrome . storage . local . get ( [ 'domainSummaryCounts' ] , function ( data ) {
623
621
const currentTab = tabs [ 0 ] ;
0 commit comments