Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to new tab disable after hit enter in javascript

(function( $ ){
    $.fn.enterAsTab = function( options ) {  
    var settings = $.extend( {
       'allowSubmit': false
    }, options);
    this.find('input, select').live("keypress", {localSettings: settings}, function(event) {
        if (settings.allowSubmit) {
        var type = $(this).attr("type");
        if (type == "submit") {
            return true;
        } 
    }
    if (event.keyCode == 13 ) {
        var inputs =   $(this).parents("form").eq(0).find(":input:visible:not(disabled):not([readonly])");
        var idx = inputs.index(this);
        if (idx == inputs.length - 1) {
           idx = -1;
       } else {
           inputs[idx + 1].focus(); // handles submit buttons
      }
        try {
            inputs[idx + 1].select();
            }
        catch(err) {
            // handle objects not offering select
            }
        return false;
    }
});
  return this;
};
})( jQuery );
Comment

PREVIOUS NEXT
Code Example
Javascript :: push a new route only triggers URL change but not location change 
Javascript :: new activexobject( adodb.connection ) javascript 
Javascript :: how to test timeout in component did mount 
Javascript :: JS glob to regex 
Javascript :: hoverintent.min.js wordpress error 
Javascript :: react hooks simple projects 
Javascript :: buscar valor maximo y mínimo array jquery 
Javascript :: react router tutorial medium 
Javascript :: dwhdjksbhds efedhgsd djsioqdhsjd 
Javascript :: javascript picture delete after time 
Javascript :: jquery read dropdown in table cell 
Javascript :: calculate string value in javascript 
Javascript :: angularjs fractionSize with dot 
Javascript :: open lightbox in backend 
Javascript :: atsby-plugin-tags npm 
Javascript :: hark javascript 
Javascript :: this rule in js:medium 
Javascript :: make directive to return dropdown values angular 
Javascript :: mongodbClint express 
Javascript :: js null vs undefine 
Javascript :: jQuery Dom ready equivalent in pure JavaScript 
Javascript :: why I can not insert image with ajax request 
Javascript :: devolver array con indice de diferencia ejemplos javascript 
Javascript :: Install React Navigation dependencies into main project folder 
Javascript :: React native-base DatePicker comes up Minimized on iOS Asked 
Javascript :: how to check in js if element is li or is button 
Javascript :: if no input given in javascript how to set default code 
Javascript :: add component to route 
Javascript :: nodejs hpp github 
Javascript :: key being passed as prop react 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =