I don't want to use validations because I'd like the alert to appear immediately after the user updated the name field.
I also want the message to be just a notification for the user and let the user decide if he wants to insert the same person multiple times.
I tried to do this with dynamic action that executes plsql code but with no success.
With that being said, I would consider using built-in APEX functionality to simplify, such as Text Field with Autocomplete. Instead of the normal text field you're using now, you could switch it to type Text Field with Autocomplete and specify an LOV query, such as:
order by 1
As the user types, they can see a list of names that already match what they're typing. In my opinion, this would be a much more elegant way to solve the problem.
Not to mention much less work, which we're all fans of :)
Here's an example of the Text Field with Autocomplete in case you haven't used it.
user = demo
pass = demo