jQuery.numeric_input

On this page you'll find a few examples that demonstrate the jQuery.numeric_input plugin

View on GitHub Download zip

Getting started

# Download the production version or the development version and apply the code below
<script src="libs/jquery/jquery.js"></script>
<script src="dist/jquery.numeric_input.min.js"></script>
<script>
$(function() {
    $("input.numeric_input").numeric_input();
});
</script>

defaults

$.fn.numeric_input.defaults = {
  decimal:          ',',    // char to append when dot or comma is pressed
  leadingZeroCheck: true,   // append a 0 when the first input is a comma or dot
  initialParse:     true,   // parse the value on start to match the decimal option
  parseOnBlur:      true,   // parse value when user lose focus on field
  allowNegative:    false   // allow value to be negative (prepends a minus char)
};

You can override the defaults globally. For instance, you can override the global default value for decimal by defining:

$.fn.numeric_input.defaults.decimal = '.';
Code
$("input.numeric_input").numeric_input();
Code
$("input.numeric_input").numeric_input({
  decimal: '.'
});
Code
$("input.numeric_input").numeric_input({
  leadingZeroCheck: false
});
Code
$("input.numeric_input").numeric_input({
  initialParse: false
});
Code
$("input.numeric_input").numeric_input({
  parseOnBlur: false
});
Code
$("input.numeric_input").numeric_input({
  allowNegative: true
});