Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have a look at this <a href="https://github.com/cstaylor/numeric.js/tree/master" rel="noreferrer">plug-in (Fork of texotela's numeric jquery plugin)</a>. <a href="http://jstepper.emkay.dk/" rel="noreferrer">This (jStepper)</a> is another one.</p> <p><a href="http://snipt.net/GerryEng/jquery-making-textfield-only-accept-numeric-values" rel="noreferrer">This</a> is a link if you want to build it yourself.</p> <pre><code>$(document).ready(function() { $("#txtboxToFilter").keydown(function (e) { // Allow: backspace, delete, tab, escape, enter and . if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110]) !== -1 || // Allow: Ctrl+A, Command+A (e.keyCode === 65 &amp;&amp; (e.ctrlKey === true || e.metaKey === true)) || // Allow: home, end, left, right, down, up (e.keyCode &gt;= 35 &amp;&amp; e.keyCode &lt;= 40)) { // let it happen, don't do anything return; } // Ensure that it is a number and stop the keypress if ((e.shiftKey || (e.keyCode &lt; 48 || e.keyCode &gt; 57)) &amp;&amp; (e.keyCode &lt; 96 || e.keyCode &gt; 105)) { e.preventDefault(); } }); }); </code></pre> <p>NOTE: If your webpage uses HTML5, you can use the built in <code>&lt;input type="number"&gt;</code> and use the <code>min</code> and <code>max</code> properties to control the minimum and maximum value.</p> <hr> <p>The following is minimized and also allows for use of <kbd>CTRL</kbd>+<kbd>X</kbd>, <kbd>CTRL</kbd>+<kbd>C</kbd>, and <kbd>CTRL</kbd>+<kbd>V</kbd></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() { $('#staticParent').on('keydown', '#child', function(e){-1!==$.inArray(e.keyCode,[46,8,9,27,13,110])||(/65|67|86|88/.test(e.keyCode)&amp;&amp;(e.ctrlKey===true||e.metaKey===true))&amp;&amp;(!0===e.ctrlKey||!0===e.metaKey)||35&lt;=e.keyCode&amp;&amp;40&gt;=e.keyCode||(e.shiftKey||48&gt;e.keyCode||57&lt;e.keyCode)&amp;&amp;(96&gt;e.keyCode||105&lt;e.keyCode)&amp;&amp;e.preventDefault()}); })</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div id="staticParent"&gt; &lt;input id="child" type="textarea" /&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload