As a rule, everything related to security or preventing the behavior of a particular user does not rely on javascript or CSS to prevent something from happening on the page. Since scripts and css can be overridden or disabled in the browser, you will not have protection from this behavior if they do.
Server side is the right place to implement precautionary measures.
In addition, note that doing this is very pleasant for users, but the server side is the only final place to prevent unwanted data doing this.
source share