Redmine Submit Guard

Avoid submit by enter key.

  1. // ==UserScript==
  2. // @name Redmine Submit Guard
  3. // @description:en Avoid submit by enter key.
  4. // @version 0.1
  5. // @namespace http://twitter.com/foldrr/
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
  7. // @match http://*/redmine/projects/*/issues/new
  8. // @match http://*/redmine/issues/*
  9. // @description Avoid submit by enter key.
  10. // ==/UserScript==
  11.  
  12. (function(){
  13. $('input').keypress(function(ev){
  14. if(ev.keyCode === 10 || ev.keyCode === 13){
  15. if(Event.element(ev).id == 'q') return true;
  16. if($('#issue_subject').val().trim() === ''){ $('#issue_subject').focus(); return false; }
  17. if($('#issue_description').val().trim() === ''){ $('#issue_description').focus(); return false; }
  18. return false;
  19. }
  20. return true;
  21. });
  22. })();