Redmine Submit Guard

Avoid submit by enter key.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name Redmine Submit Guard
// @description:en Avoid submit by enter key.
// @version 0.1
// @namespace http://twitter.com/foldrr/
// @require   http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @match     http://*/redmine/projects/*/issues/new
// @match     http://*/redmine/issues/*
// @description Avoid submit by enter key.
// ==/UserScript==

(function(){
    $('input').keypress(function(ev){
        if(ev.keyCode === 10 || ev.keyCode === 13){
            if(Event.element(ev).id == 'q') return true;
            if($('#issue_subject').val().trim()     === ''){ $('#issue_subject').focus();     return false; }
            if($('#issue_description').val().trim() === ''){ $('#issue_description').focus(); return false; }
            return false;
        }
        return true;
    });
})();