Check length of value and if it is numeric
<p>I am using the following code to check if the value in a textbox is numeric:</p>

<pre><code>(function ($) {
    $.fn.numeric = function (options) {
        return this.each(function () {
            var $this = $(this);

            $this.keypress(options, function (e) {
                // allow backspace and delete
                if (e.which == 8 || e.which == 0)
                    return true;

                //if the letter is not digit
                if (e.which &lt; 48 || e.which &gt; 57)
                    return false;

                // check max range
                var dest = e.which - 48;
                var result = this.value + dest.toString();
                if (result &gt; e.data.max) {
                    return false;
                }
            });
        });
    };
})(jQuery);
</code></pre>

<p>When using on an input textbox element, I declare it as follows </p>

<pre><code>$(input).numeric({ max: 999});
</code></pre>

<p>The problem is that it's working on input and checking that
value should be integer and not string.</p>

<p>But I need to change code that it will validate double as well.</p>

<p>So if I will insert 0.22 it will be OK, but if I will insert .22 
it will not populate the number.</p>

<p>Please help </p>
