Skip to content

A simple plugin for doing simple inline calculation inside any <input>

License

Notifications You must be signed in to change notification settings

yearski/jQueryCalculadora

 
 

Repository files navigation

jQueryCalculadora

A simple plugin for doing simple inline calculation inside any <input>

Always loved to make simple calculations inside any number textbox on MS Money, now you can do it with jQuery also. I skipped showing the calculator, because it will create big trouble maintaining the focus in the input, but show a nice ticket with the past operations.

This is my first jQuery plugin and first GitHub project, so have mercy :)

Demo

Demo

Gif Demo

Options

  • decimals Number of decimals to show in the ticket and in the result value. Default is '2'
  • useCommaAsDecimalMark If true, use the comma to parse the numbers and to show the values. Default is 'false'
  • numberFormat Intl.NumberFormat() which can contain further formatting options. See: MDN: NumberFormat for more. Optional. Will default to 'US' if useCommaAsDecimalMark is provided and true, or 'FR' if useCommaAsDecimalMark is provided and false
  • parent_element Parent element to attach the calculator "ticket", use to control visibility. Default is $("body")

Usage


    $(function () {
        $("input").calculadora({decimals: 0, useCommaAsDecimalMark: false});
    })

Or:


    const nF = new Intl.NumberFormat('US', {style: 'decimal', maximumFractionDigits: 2, useGrouping: false});
    $("input.calculator").calculadora({numberFormat: nF, parent_element: $('.modal-body')});

About

A simple plugin for doing simple inline calculation inside any <input>

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 64.6%
  • HTML 28.6%
  • CSS 6.8%