javascript - How to prevent only closing of bootstrap modal on backspace keypress -


i have form in bootstrap modal. have disabled backspace button when bootstrap modal open code

$('body').keydown(function (e) {         if ($('#mymodal').is(':visible')) {             if (e.keycode == 8) {                  return false;             }         } }); 

in bootstrap modal form have textbox, textarea need backspace button there. not able use backspace button in textbox in bootstrap modal form

solution:

$('body').keydown(function (e) {     if ($('#mymodal').is(':visible')) {         var rx = /input|select|textarea/i;         if (e.keycode == 8) {             if(!rx.test(e.target.tagname) || e.target.disabled || e.target.readonly ){                 e.preventdefault();             }         }     } }); 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -