Preventing Unauthorized Form Editing with JavaScript

Hello everyone,

I’m trying to use JavaScript to prevent users from editing fields and instead show a message that they don’t have permission. When I click the edit button, the message appears saying the user should log in, but it still allows access to the forms where editing is possible. See the attached images.
Bildschirmfoto vom 2024-12-19 14-15-40
Bildschirmfoto vom 2024-12-19 14-16-26