Tuesday, November 22, 2011

JQuery snippets

JQuery is the one of the awesome in javascrijpt. Here i list out some snippets

Disable the "Enter" key form submit


By default all HTML forms will submit when Enter key pressed. Sometime it will trouble. Using jquery we can easily disable the short cut.Here is the code we can easily prevent the form submit using enter key.

$("#form").keypress(function(e) {
  if (e.which == 13) {
    return false;
  }
});

Source : http://snipplr.com/view/10943/disable-enter-via-jquery/

Disable right click


Some time we want to disable the right click in a page, via JQuery it also easy one.Here is the code snippet for this one

$(function() {
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
});

Using the above one you can prevent the right click in your pages

Source : http://snipplr.com/view/34189/

No comments:

Post a Comment