
decimal-input is a small JavaScript plugin that automatically formats and restricts the number input to only allow decimal values.
How to use it:
1. Download and insert the JavaScript decimal-input.js into the HTML file.
<script src="./decimal-input.js"></script>
2. Initialize the plugin on the number input and done.
<input class="decimal" type="number">
decimalInput();
3. Set the formatting type. Default: ‘standard’.
<input class="decimal" type="number" data-format="height">
// or
decimalInput({
format: "height"
});4. Set the number of decimal places. Default: 2.
<input class="decimal" type="number" data-length="3">
// or
decimalInput({
length: 3
});5. It also provides a basic validator for height, which can be used to correct feet and inches values.
decimalInput({
validation: "soft" // or 'hard'
});6. Override the default selector.
decimalInput({
selector: ".decimal"
});Changelog:
09/05/2023
- Bugfixed
03/28/2020
- Update decimal-input.js
03/25/2020
- Added support for Android







