HTML text input allow only numeric input

Note: This is an updated answer. Comments below refer to an old version which messed around with keycodes. JavaScript Try it yourself on JSFiddle. You can filter the input values of a text <input> with the following setInputFilter function (supports Copy+Paste, Drag+Drop, keyboard shortcuts, context menu operations, non-typeable keys, the caret position, different keyboard layouts, … Read more

Tainted canvases may not be exported

For security reasons, your local drive is declared to be “other-domain” and will taint the canvas. (That’s because your most sensitive info is likely on your local drive!). While testing try these workarounds: Put all page related files (.html, .jpg, .js, .css, etc) on your desktop (not in sub-folders). Post your images to a site … Read more

JQuery: $.get is not a function

The $ variable you have is from Prototype-js, because you are using the jQuery.noConflict method. That method will restore the $ variable back to whichever library first implemented it. You should use the jQuery methods on the jQuery global object directly, eg.: Or you can define another shorter variable as alias if you want:

Is it possible to stop JavaScript execution?

Short answer: If you want to know more, keep reading. Do you want to stop JavaScript’s execution for developing/debugging? The expression debugger; in your code, will halt the page execution, and then your browser’s developer tools will allow you to review the state of your page at the moment it was frozen. Do you want … Read more

Initializing an Array with a Single Value

no initialization (that i know of) Update Since ever posting this answer 4 years ago, people seem to keep coming back here for this answer. For benchmarking purposes I made a JSPerf with some different solutions. The solution above here isn’t the quickest, although it’s short. To stick to the same short style, but with … Read more