Force Numeric Input

by shapeshifta

HTML

<input class="numeric" value="" />

JavaScript

(function($) {
    $.fn.forceNumericOnly = function() {
        return this.each(function() {
            $(this).on('keyup focusout', function(e) {
                this.value = this.value.replace(/[^0-9\,()\+\-]/g, '');
            });

        });
    };

    $('input.numeric').forceNumericOnly();
})(jQuery);