Jump to content

User:Ilmari Karonen/signcheck.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// CHECK THAT I'VE REMEMBERED TO SIGN TALK PAGES: <pre><nowiki>

if (mw.config.get('wgNamespaceNumber') % 2 === 1 && (mw.config.get('wgAction') === "edit" || mw.config.get('wgAction') === "submit")) {  // editing a talk page?
    $(function () {
        if (!document.editform || !document.editform.wpSave || !document.editform.wpTextbox1) return;
        var oldOnclick = document.editform.wpSave.onclick;
        document.editform.wpSave.onclick = function () {
            if (oldOnclick && !oldOnclick.apply(this, arguments)) return false;
            if (document.editform.wpTextbox1.value.match(/~{3}/)) return true;
            return confirm("You have not signed your name. Save anyway?");
        };
    });
}

// </nowiki></pre>