(function($){
	$.fn.alphanumeric = function(p) {		
		p = $.extend({
			allowDecimal: false
		  }, p);
		return this.each
			(
				function() 
				{
					var adn = p.allowDecimal;

					$(this).keypress
						(
							function (e)
								{

									var keyResult = numbersonly(e, adn);
									if (!keyResult) {
										if (e.preventDefault) {
											e.preventDefault(); 
										}
										return false;										
									}	
									
								}
								
						);
					$(this).bind('contextmenu',function () {return false});
				}
			);
	};
	$.fn.numeric = function(p) {
		return this.each (function()
			{
				$(this).alphanumeric(p);
			}
		);
	};
})(jQuery);

function numbersonly(e, allowDecimal) {
	var key;
	var keychar;
	if (window.event) {
	   key = window.event.keyCode;
	}
	else if (e) {
	   key = e.which;
	}
	else {
	   return true;
	}
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) || (e.ctrlKey && ((key==118) || (key==99)))) {
	   return true;
	}
	else if ((("0123456789").indexOf(keychar) > -1)) {
	   return true;
	}
	else if (allowDecimal && ((keychar == ".") || (keychar == ","))) { 
	  return true;
	}
	else
	   return false;
}
