$.fn.extend({ // Extender el núcleo de JQuery para poder hacer uso de la función reset() de un formulario en JQuery reset: function(){ return this.each(function() { $(this).is("form") && this.reset(); }); }, // Forzar números en campos input forceNumericOnly: function() { return this.each(function() { $(this).keydown(function(e) { var key = e.charCode || e.keyCode || 0; // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY return ( key == 8 || key == 9 || key == 46 || (key >= 37 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105)); }); }); } }); $.extend({ // Codificar URL URLEncode: function(c) { var o="";var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/; while(x1 && m[1]!='') { o+=m[1];x+=m[1].length; } else { if(c[x]==" ") { o+="+"; } else { var d=c.charCodeAt(x);var h=d.toString(16);o+="%"+(h.length<2?"0":"")+h.toUpperCase(); }x++; } } return o; }, // Defocificar URL URLDecode: function(s) { var o=s;var binVal,t;var r=/(%[^%]{2})/; while((m=r.exec(o))!=null && m.length>1 && m[1]!='') { b=parseInt(m[1].substr(1),16);t=String.fromCharCode(b);o=o.replace(m[1],t); } return o; } });