Plugin to make labels mandatory on every page

Hello,

Is there a way to ensure a label must be entered before publishing or updating a page?
A popup should appear if no label is entered.

First I tried including a JavaScript in custom HTML:

<script type="text/javascript" src="/confluence/includes/js/label_alert.js"></script>

At the moment the script looks like this:

&lt;script type="text/javascript"&gt;
AJS.toInit(function(){
   AJS.$('#rte-button-publish').click(function(e){
      alert("Please add at least one or more labels");
   });
});
&lt;/script&gt;

I have the code from this post: Solved: Mandatory labels in Confluence

Since it is the first time that I do something with custom html and javascript, I do not know if it is correct at all. In any case, I don’t get any alerts.

I am now trying to develop my own plugin.
Can you guide me in the right way so that I habe a good start and can achieve my goal?

I would be grateful for any help!

Hello Florian,

Not an answer, but generally “only” JavaScript/HTML is not a bulletproof solution as it doesn’t force the requirement on the server side, but probably works for most users.

You may have a look at, maybe this has such a feature: Comala Document Management | Atlassian Marketplace

We also have this as a feature request for our Label Suggester for Confluence | Atlassian Marketplace but still not done anything in this direction.

Hello, can the orginal authour let us know if his script worked?