Jquery is not allowing line breaks in text areas-Collection of common programming errors

I’m having a weird issue. When adding support for Jquery 1.7.2, I am unable to add line-breaks to textareas in forms. When I click, enter, nothing happens.

I fiddled with the source code in jquery, and found that if I commented out the following code (on line 4845)

for ( var type in Expr.match ) {
    Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
    Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
}

the ability to add line breaks was restored. I’m not seeing anyone else having this issue, so I’m guessing something else is going on. However, my question is: what is the purpose of the code above (I’m not very javascript-savvy), and does removing it pose any risk? I’d like to just remove the code and restore line break ability to textareas, but don’t want to bork the site unknowingly. I did notice that after doing this, I’m seeing an error in the js console:

Uncaught TypeError: Cannot call method 'exec' of undefined -- jquery.js:4185

Any help would be greatly appreciated!

Here is some code sample. The html:

    
  
    
  1. Activity Type * CallConnectivity MeetingConversationEmail (incoming)Email (outgoing)Implementation NotesMeeting MinutesTaskTip / Unusual Attribute
  2. Summary *
  3. Details 
  
  
  

And the javascript that isn't included with other plugins:


// Dynamic lookup of C2 companies
$(document).ready(function ()
{
  $(window).keydown(function(event)
  {
    if(event.keyCode == 13) 
    {
      event.preventDefault();
      return false;
    }
  });
  $("#search_input").autocomplete(
  {
    source: function(request,response)
    {
      $("#loading-search").show();
      $("#no-results").hide();
      $.getJSON("/services/json/cust_search.php",request,function(data) 
      {
        response(data);
        $("#loading-search").hide();
        if (data.length == 0)
        {
          $("#no-results").show();
        } else
        {
          $("#no-results").hide();
        }
      });
    },                                              
    minLength: 3,
    select: function(event,ui)
    {
      $("#search_input").hide();
      $("#search_input").val(ui.item.value);
      $("#search_source").val(ui.item.source);
      $("#search-form").submit();
    } 
  });
});
 

//---------------------------------------------------------------------------
//  Hide all the submenus on start.  When a non-expanded menu is clicked,
//  expand that menu while collapsing the menu above it.  If a menu is 
//  clicked when its expanded, collapse.
//---------------------------------------------------------------------------
$(function() 
{
//  $("dd:not(:first)").hide();
  $("dd").hide();
  $("#menu-nexmark").slideDown("fast");
  $("dt a").click(function() 
  {
    var curr_dd = $(this).parent().next();
     if (curr_dd.css("display") != "none")
    {
      $("dd:visible").slideUp("medium");
      return;
    }
    $("dd:visible").slideUp("slow");
    curr_dd.slideDown("slow");
    return false;
  });
});

  1. The issue was this code:

    $(window).keydown(function(event)
      {
        if(event.keyCode == 13) 
        {
          event.preventDefault();
          return false;
        }
      });
    

    Setting it to refer to only the div it impacted (an autocomplete search menu we wanted to disable the ability to click enter on), restored line break functionality everywhere else:

    $("#somediv").keydown(function(event)
      {
        if(event.keyCode == 13) 
        {
          event.preventDefault();
          return false;
        }
      });
    

Originally posted 2013-11-15 09:09:19.