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

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

defaults

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

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

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