Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

field What did you change? required

SRBR SE March 27, 2015

Is it possible require the field What did you change?

The user only can save a page if input some information.

I tried used this code:

jQuery(function(){      
        var saveEnabledTitle = 'Save your page ( Type \'Ctrl+S\' )'
        var previewEnabledTitle = 'Preview ( Type \'Ctrl+Shift+E\' )'
        var saveDisabledTitle = 'Please enter a change comment before saving';
        var previewDisabledTitle = 'Please enter a change comment before previewing'; // confluence UI limitation
 
        var saveButtonCheck = function() {
                var commentField = jQuery('#rte-savebar #versionComment');
                if (commentField.length == 0 || !$(commentField).is(':visible')) return;
 
                if (commentField.val().length > 0) {
                        jQuery('#rte-savebar #rte-button-publish')
                          .enable()
                          .attr('title', saveEnabledTitle);
                        jQuery('#rte-savebar #rte-button-preview')
                          .enable()
                          .attr('title', previewEnabledTitle);
                } else {
                        jQuery('#rte-savebar #rte-button-publish')
                          .disable()
                          .attr('title', saveDisabledTitle);
                       
 // note: have to disable preview too, since it doesn't work if the 
publish button is disabled. Probably a workaround but pretty complex.
                        jQuery('#rte-savebar #rte-button-preview')
                          .disable()
                          .attr('title', previewDisabledTitle);
                }
        }
        saveButtonCheck();
        jQuery('#rte-savebar #versionComment').keyup(saveButtonCheck);
        $('.aui-buttons.toolbar-group-preview, .save-button-container').click(function() { $('#versionComment').focus(); })});

 

 Its working perfectly, but to execute is necessary open the page and refresh it.

Could be default when edit any page...

 

Any susgestion ?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Enterprise Procurement August 12, 2015

We are using Confluence 5.8.5 local instance and I can't get this to work. Can you be more clear where you're putting your script? Thank you

TAGS
AUG Leaders

Atlassian Community Events