GithubHelp home page GithubHelp logo

shaack / bootstrap-input-spinner Goto Github PK

View Code? Open in Web Editor NEW
229.0 10.0 160.0 369 KB

A Bootstrap plugin to create input spinner elements for number input

License: MIT License

JavaScript 83.07% HTML 15.98% CSS 0.95%
bootstrap jquery jquery-plugin spinner ui frontend input

bootstrap-input-spinner's Introduction

bootstrap-input-spinner

A Bootstrap / jQuery plugin to create input spinner elements for number input.

Note: bootstrap-input-spinner is now a ES6 module. You find the old ES5 version under es5-deprecated. The ES5 version is not maintained anymore and will be removed in the future.

Demo page with examples

bootstrap-input-spinner Examples with floating-point and german localization

This version is compatible with Bootstrap 5, but we remain a Bootstrap 4 compatible version with the branch bootstrap4-compatible. npm package versions 3.x are Bootstrap 5 compatible, versions 2.x Bootstrap 4 compatible.

Features

The Bootstrap InputSpinner

  • is mobile friendly and responsive,
  • automatically changes the value when holding a button,
  • has internationalized number formatting,
  • allows setting a prefix or a suffix text in the input,
  • handles val() like the native element,
  • dynamically handles changing attribute values like disabled or class,
  • supports templates and custom editors, (new!)
  • dispatches change and input events on value change like the native element and
  • works without extra css, only Bootstrap 5 is needed.

Quickstart

Installation

Current version, Bootstrap 5 compatible

npm install bootstrap-input-spinner

Bootstrap 4 compatible version

npm install [email protected]

Or just download the GitHub repository and include src/bootstrap-input-spinner.js.

HTML

Create the element in HTML. The attributes are compatible to the native input[type="number"] element.

<input type="number" value="50" min="0" max="100" step="10"/>

Script

<script type="module">
    import {InputSpinner} from "./src/InputSpinner.js"

    const inputSpinnerElements = document.querySelectorAll("input[type='number']")
    for (const inputSpinnerElement of inputSpinnerElements) {
        new InputSpinner(inputSpinnerElement)
    }
</script>

That's it. No extra css needed, just Bootstrap 5 and jQuery. (Note: jQuery will be removed in the future)

API Reference

HTML Attributes

<input type="number" value="4.5" min="0" max="9" step="0.1" data-decimals="2" data-suffix="°C"/>

Use these attributes to configure the behaviour

  • value // starting value on element creation
  • min // minimum value when stepping
  • max // maximum value when stepping
  • step // step size
  • inputmode // the "inputmode" of the input, defaults to "decimal" (shows decimal keyboard on touch devices)
  • data-decimals // shown decimal places
  • data-digit-grouping // "false" to disable grouping (thousands separator), default is "true"
  • data-prefix // show a prefix text in the input element
  • data-suffix // show a suffix text in the input element

The InputSpinner also handles the standard input attributes required, disabled, readonly and placeholder.

Create an instance in JavaScript

Use JavaScript to create the instance as a jQuery plugin. You may provide additional configuration in an object as a config parameter.

$(element).inputSpinner(config);

Configuration (props)

The default configuration is

var props = {
    decrementButton: "<strong>&minus;</strong>", // button text
    incrementButton: "<strong>&plus;</strong>", // ..
    groupClass: "", // css class of the resulting input-group
    buttonsClass: "btn-outline-secondary",
    buttonsWidth: "2.5rem",
    textAlign: "center", // alignment of the entered number
    autoDelay: 500, // ms threshold before auto value change
    autoInterval: 50, // speed of auto value change, set to `undefined` to disable auto-change
    buttonsOnly: false, // set this `true` to disable the possibility to enter or paste the number via keyboard
    keyboardStepping: true, // set this to `false` to disallow the use of the up and down arrow keys to step
    locale: navigator.language, // the locale, per default detected automatically from the browser
    editor: I18nEditor, // the editor (parsing and rendering of the input)
    template: // the template of the input
        '<div class="input-group ${groupClass}">' +
        '<button style="min-width: ${buttonsWidth}" class="btn btn-decrement ${buttonsClass} btn-minus" type="button">${decrementButton}</button>' +
        '<input type="text" inputmode="decimal" style="text-align: ${textAlign}" class="form-control form-control-text-input"/>' +
        '<button style="min-width: ${buttonsWidth}" class="btn btn-increment ${buttonsClass} btn-plus" type="button">${incrementButton}</button>' +
        '</div>'
}
decrementButton, incrementButton

HTML of the texts inside the buttons.

groupClass

Additional css class for the input-group of the rendered Bootstrap input.

buttonsClass

The css class of the buttons. Use it to style the increment and decrement buttons as described here. Maybe buttonsClass: btn-primary or btn-success or whatever type of buttons you want.

buttonsWidth

The width of the increment and decrement buttons.

textAlign

The text alignment inside the <input>.

autoDelay

The delay in ms after which the input automatically changes the value, when holding the increment or decrement button.

autoInterval

Speed of the value change when holding the button in ms. A lower value makes it faster.

buttonsOnly

In buttonsOnly mode (set true) no direct text input is allowed, the text-input gets the attribute readonly, but the plus and minus buttons still allow to change the value.

keyboardStepping

In keyboardStepping mode (set true) allows the use of the up/down arrow keys to increase/decrease the number by the step.

locale

Used to format the number in the UI. Detected automatically from the user's browser, can be set to "de", "en",… or " de_DE", "en_GB",….

editor (new!)

An Editor defines, how the input is parsed and rendered. The default editor of the spinner is the I18nEditor, which renders and parses an internationalized number value. There are custom editors in /src/custom-editors.js. An Editor must implement the two functions parse(customValue), to parse the input to a number and render(number) to render the number to the spinner input.

The simplest custom Editor is the RawEditor, it renders just the value und parses just the value, without any changes, like a native number input. It looks like this:

var RawEditor = function (props, element) {
    this.parse = function (customFormat) {
        // parse nothing
        return customFormat
    }
    this.render = function (number) {
        // render raw
        return number
    }
}

props is the configuration of the spinner and element is the original HTML element. You can use these values for the configuration of the Editor, like in I18nEditor, which uses props for the language and element for the attributes.

The TimeEditor renders and parses the number to time in hours and minutes, separated by a colon.

bootstrap-input-spinner Supports custom editors to parse and render everything

template

To modify the look completely, you can use the template parameter. There is an example about this on the Demo Page.

Programmatic change and read of value

To change or read the value just use the jQuery val() function on the input, like this

var currentValue = $(element).val() // read
$(element).val(newValue) // write

Hint: Reading the value in vanilla JS with element.value will also work, but to set the value you have to use element.setValue(newValue) or $(element).val(newValue)

Handling attributes

The attributes min, max, step, decimals, placeholder, required, disabled, readonly and class are handled dynamically. The class attribute value is dynamically copied to the input element.

Sizing

If the original elements class is set to form-control-sm of form-control-lg the class of the resulting input-group is dynamically set to input-group-sm or input-group-lg.

Events

The InputSpinner handles input and change events like the native element.

Event handling with vanilla JavaScript

element.addEventListener("change", function (event) {
    newValue = this.value
})

Event handling with jQuery syntax

$(element).on("change", function (event) {
    newValue = $(this).val()
})

Methods

Methods are passed as string values instead of the options object.

destroy

Removes the InputSpinner and shows the original input element.

$(element).inputSpinner("destroy")

Minified version

I don't provide a minified version because I think it should be up to the using programmer to create minified versions, with all the used script sources concatenated to one file.

But, if you want it, it is easy to create your minified version with uglify: https://www.npmjs.com/package/uglify-js

Just install uglify

npm install uglify-js -g

and then in the src-folder

uglifyjs bootstrap-input-spinner.js --compress --mangle > bootstrap-input-spinner.min.js

Violà! :)

Browser support

The spinner works in all modern browsers and Internet Explorer. Not tested with IE < 11.

For older browsers (IE 9 or so), that doesn't support Intl, when you get an error message like "Intl is not defined" (See issue #34), just use a shim or polyfill like Intl.js, and it works.

You may want to check out my further Bootstrap and HTML extensions

bootstrap-input-spinner's People

Contributors

aaroncat007 avatar alexndlm avatar cappi1998 avatar coliff avatar dependabot[bot] avatar jboyer87 avatar jcputney avatar jeremyv2014 avatar jpbetley avatar maurojs10 avatar paulzzh avatar shaack avatar thijstriemstra avatar v-ed avatar villu164 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bootstrap-input-spinner's Issues

Bug on Safari and iOs devices

Hello,

it seems that Apple has stopped using the Intl librairy :

line 238 : ReferenceError: Can't find variable: Intl

Is there a way to fix it ?

Thank you

when spinner max value is 0 the upper limit is not respected.

With the following control:
<input id="<anythig>" name="<anythig>" type="number" value="0" min="-10" max="0">
The upper limit of zero is not being respected.
The problem is in line 65 of the file:
var max = parseFloat($original.prop("max")) || Infinity
in the case of max = 0 as a valid value 0 || Infinity => Infinity
Proposed correction:
var max = isNaN($original.prop("max")) ? Infinity : parseFloat($original.prop("max"))
Only if max is not a valid number the Infinity will be assigned.

Delay after keyup at change event?

I want to use this nice library to send AJAX data if value changed. But with the normal solution it will send the data to often. Do you have an idea to call the change event some seconds after the keyup event detected and if a user press it again the timeout will reset.

Dynamically modify minimum / maximum

I want to be able to modify the min / max values of the spinner based on events on the page. If the user selects certain options in the form, then the valid range of values should change based on that.

It looks like the min and max are read and stored in the JS procedure on the call to inputSpinner(), and are not modifiable after that.

Doubling the code

Script creates two widgets at the time on every number input

Снимок экрана 2020-04-01 в 16 58 27

Two input groups
Снимок экрана 2020-04-01 в 16 59 48

call:

$("input[type='number']").inputSpinner();

"Invalid regular expression" error when thousandSeparator is empty string

How to reproduce:

  1. Change system region format to Russian.
  2. Click on input spinner to input value by typing
  3. Type any number

You should see an error:
bootstrap-input-spinner.js:256 Uncaught SyntaxError: Invalid regular expression: /\/: \ at end of pattern at new RegExp (<anonymous>) at parseLocaleNumber (bootstrap-input-spinner.js:256) at HTMLInputElement.<anonymous> (bootstrap-input-spinner.js:113)

Reasoning
On Russian locale, there's no separator for thousands. Hence, this line
var thousandSeparator = numberFormat.format(1111).replace(/1/g, '')
produces an empty string. Then the next line
new RegExp('\\' + thousandSeparator, 'g'), '')
makes a regexp /\/, which makes an error and doesn't change the input spinner val.

plus and minus icons are not showing

Hello there

I'm running this in localhost. The plus and minus sign of the spinner are not showing up. The browser only shows a default spinner

here is my page

`
<!doctype html>

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="css/styles.css" >

<!-- JQuery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>

<!-- Extra scripts for BS  -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<script src="http://localhost/front-end/js/bootstrap-input-spinner.js"></script>

<script>
    jQuery("input[type='number']").inputSpinner()
</script>

<script>
  jQuery( function() {
    jQuery( ".datepicker" ).datepicker();
  } );
</script>
<div class="form-container">

  <form class="form-horizontal" action="" method="POST">

      <!-- Number of adults-->
      <div class="form-group">
        <label class=" control-label" for="adults">Adults</label>
        <div class="">
          <input name="adults" type="number" value="0" min="0" max="5" step="1" />
        </div>
      </div>

      <!-- Number of children -->
      <div class="form-group">
        <label class="control-label" for="children">Children</label>
        <div class="">
           <input name="children" type="number" value="0" min="0" max="5" step="1"/>
        </div>
      </div>

      <!-- Number of infants -->
      <div class="form-group">
        <label class=" control-label" for="infants">Infants</label>
        <div class="">
          <input name="infants" type="number" value="0" min="0" max="5" step="1"/>
        </div>
      </div>

     

      </fieldset>
      </form>

     </div>

`

TypeError: this[0] is undefined

Getting: TypeError: this[0] is undefined bootstrap-input-spinner.js:14:13

Ended up changing:

if (this[0]["bootstrap-input-spinner"] && this[0].setValue) { this[0].setValue(value) }

to

if (this["bootstrap-input-spinner"] && this.setValue) { this.setValue(value) }

bootstrap-input-spinner inside datatables responsive

Hi,
I am using bootstrap-input-spinner inside datatables responsive and it works perfect on desktop or on mobile devices with hi res.
But on mobiles or low res the numbers disappear.
Only inside datatables, outside still perfect.
anyone ?
Just me ?

Enable spinner via ajax

First, this library is very helpful, thank you!

At some point in my project I build a dynamic form after an AJAX call. The form is dynamically placed in a modal and launched. The spinner however won't initialize... The spinners which are in the page at pageload are working fine.

Any ideas?
Thanks

Unwanted thousand seperator

Hi,

Just a note to those not wanting any separators/grouping (and maybe a feature request), eg when using number input for years or because of issues parsing the symbol.

obviously, you could add another property/variable and use that, but as a quick fix, this works.

on line 76 you should find this:

        var numberFormat = new Intl.NumberFormat(locale, {
            minimumFractionDigits: decimals,
            maximumFractionDigits: decimals               
        });

simply add useGrouping: false to the options, making:

        var numberFormat = new Intl.NumberFormat(locale, {
            minimumFractionDigits: decimals,
            maximumFractionDigits: decimals,
            useGrouping: false
        });

Thanks!

Number Formatting

Hello can I remove number formatting (1,000 => 1000)

Regards
Bogdan

Input issue

non-numeric symbols except '.' might not be available )))

autoInterval not cleared when element is disabled

If the button is being held when the element is put into the disabled state, AutoInterval will cause it to keep counting up/down. Also, the onPointerUp is not always fired for the disabled element which can cause it to be stuck counting up/down indefinitely.

To Reproduce

On a page with the following HTML, click and hold on the plus button of the input spinner. Once it begins counting up, release the mouse button.

<input type="number">
<script>
	$('input[type=number]').on('change', function() {
		$(this).prop('disabled', true);
	}).inputSpinner();
</script>

Suggested Fix

In the updateAttributes function, add code that checks for the disabled state conditionally resets the autoIntervalHandler timer. For example,

var disabled = $original.prop("disabled")
$input.prop("disabled", disabled)
$buttonIncrement.prop("disabled", disabled)
$buttonDecrement.prop("disabled", disabled)
if (disabled) {
	resetTimer()
}

Change data-decimals attribute dynamically

I have <input type="number" id="input-spinner" data-decimals="1" ...> in my html and I try to change data-decimals attribute dynamically from '1' to '0' but it doesn't work, nothing changes:
$('#input-spinner').prop('data-decimals', '0');
How can I fix it?

Restrict characters in input field

$(document).ready(function() { $("input").keydown(function (e) { // Allow: backspace, delete, tab, escape and enter if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110]) !== -1 || // Allow: Ctrl+A (e.keyCode == 65 && e.ctrlKey === true) || // Allow: home, end, left, right (e.keyCode >= 35 && e.keyCode <= 39)) { // let it happen, don't do anything return; } // Ensure that it is a number and stop the keypress if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { e.preventDefault(); } }); });

Updating the value doesn't show on the input spinner

For some strange reason, the value of the input spinner is not shown (or updated) when it's set manually using a jQuery statement like:

$('input.input-spinner').val(count);

Is there something obvious I'm missing? Consider the html fragments below. When I debug the code and inspect the spinner object, I can see the value is updated but the UI doesn't reflect this.

<div class="form-row">
        <div class="col-2">
            <input class="input-spinner" type="number" min="0" max="25" step="1" />
        </div>
        <div class="col">
            <button class="btn btn-primary">Set!</button>
        </div>
</div>    

And the script

<script>

        $('button.btn-primary').on('click', function (e) {
            var count = 10;

            console.log("Setting count on spinner: " + count);
            
            var spinner = $(this).closest('.form-row').find('input.input-spinner');
            spinner.val(count);
        });

        $('input.input-spinner').on('change', function (e) {
            var count = $(this).val();
            if (count === "")
                return;

            console.log("Spinner count: " + count);
        })

        $('input.input-spinner').InputSpinner();        

</script>

Also, in the fragment above, the Change events is fired on initializing the spinner, is that a known issue?

Intl is not defined

Some browsers do not support the object Intl.

If do not want to support older browsers, is there a way to disable this feature?

BUG: min max and value change at the same time

<input id="test" type="number" step="1" />

And two button btn1 btn2 . btn.onClick=test1() and btn2.onClick=test2()

function test1() {
        $("#diskNum").attr("min", 11)
        $("#diskNum").attr("max", 1000)
        $("#diskNum").val(45)
    }

function test2() {
    $("#diskNum").attr("min", 1)
    $("#diskNum").attr("max", 10)
    $("#diskNum").val(5)
}



click btn1, it shows 45. Click btn2 , it shows 10. And click btn2 again, it shows 5.
Why?
It can't change min/max/val at the same time?

Usage with angularJS. Increment decrement doesn't work.

This is what I tried -

//included js by downloading src file : bootstrap-input-spinner.js

<script th:src="@{/js/bootstrap-input-spinner.js}"></script>
<script>
	$("input[type='number']").inputSpinner();
</script>

I see the spinner but click on "+"/"-" doesn't change the value.

Screen Shot 2019-04-17 at 5 56 32 PM

Am I missing something here?

Another weird thing I noticed - if I init $("input[type='number']").inputSpinner(); in a my page js file for eg:
$(document).ready(function () {
$("input[type='number']").inputSpinner();
}

+/- click works but placeholders are shown incorrectly
image
so here, instead of 1, I see 0 in the textbox of spinner

Behaviour is not exactly like the native input[type='number']

For a quick test, simply set data-step="2", set the value to 5, and try to decrement : expected 3, got 2. You can also do this test in your live demo in your "Dynamically handling of min, max, step and data-decimals" section (sidenote : would be nice if there was ids to your page sections, so we could link them directly in links!).

Same goes with increment, incrementing an odd number by an even number does not give the expected result (with the last example, I would expect 5 + 2 = 7, but 8 is currently being produced).

I realized that by doing some tests on my own fork, and tracing back I found that you changed to a rounding logic in this commit : be6b7c8, and now I'm wondering what is that "better form handling".

A fix for this would be to change this line :

setValue(Math.round(value / step) * step + step)

to :

setValue(value + step)

... but I figure there was an issue to doing simply that, as this is what you had previously... so here's an issue to discuss about it :)

Localisation based on project needs

Here is a real scenario:
I am working on a project where a user has to input an amount in Euro. The project is local-based in Greece so the locale is strictly with comma , as decimal separator and dot . as thousand seperator.

I am using a macOS environment which is in english with greek localisation. But all my browsers (chrome, firefox, safari) are in english and none of them doesn't seem to understand my localisation. So the display of this input field for decimal is with dot . instead of comma.
I assume that there are a lot of others with the same configuration as mine.

Think also that a greek user who lives in a foreign country and she has to complete the form with the amount field of course in Euro currency but her browser configuration is in different localisation.

It's frustrating. I understand that it may be a browser issue, but as developers we have to give the right UX to our users.

I propose to bring back as config option the locale and keep as fallback the navigator.language. If there is a multi-language website and there is need of both decimal point display, the locale could be loaded dynamically in config through language url parameter.

Change event is fired on (page) initialization

For some reason, when I hook up the code below, the change event is fired when the InputSpinner is initialized. Is there any reason for this? Or how to prevent this?

$('input.input-spinner').on('change', function (e) {
  var count = $(this).val();        
  console.log("Spinner count has changed: ", count);
});       

$('input.input-spinner').InputSpinner();

Using a number keyboard on mobile devices / setting the input pattern.

As currently written, the plugin has the "type" property of the resulting input hard-coded as "text". This creates a type="text" input regardless of the original input type (for example, "number"). This hurts the "mobile-friendliness" claim of the addon because if a user tries to interact with an input that is supposed to be of a particular type, the mobile browser will instead revert to full-text input.

Change button style

First, this library is very helpful, thank you!

Can I change style of the buttons (eg. btn-outline-secondary to btn-secondary) without hacks?

Bootstrap 4 vertical alignment

I'm using bootstrap 4 and displaying this in an html table cell. In the attached image you will note that the vertical alignment is different from the other controls in the table row. The other inputs around it are all "form-control-sm" and I have initialized as follows:

$("input[type='number']").inputSpinner({
groupClass: "input-group-sm",
buttonsWidth: "0.5rem"
});

Capture

Spinner Not Stopping on max value

My spinner will not stop on max amount. It goes 2 steps above every time if you just hold it down. Once you click back on it goes to max and then starts down if you pressing down. This happens to all the spinners I have on the page also.

Add possibility to enable/disable control

The plugin is not detecting disabled option of the parent input control.
Will be good to have such possibility and also possibility to enable/disable it programmatically.

Using the spinner with Vuejs

Not so much of an issue, rather a question. I really like this implementation of the input spinner, for its simplicity and integration with bootstrap. Were currently evaluating the use of Vuejs for a project where we input spinner is used, any chance we could use the spinner together with Vue?

destroy

how to destroy instances?

Issues with Bitwarden (Password Manager)

"A picture is worth a thousand words".

I am trying to show the issue with an animated gif here:
input_fromDesktop

Here is a typical example of bootstrap-input-spinner rendered in a form and working in a dekstop computer. What i am trying to do, is to type the amount of "3,45" or "3.45" (if you prefer). As you can see by the keystrokes i haved demostrated, it's almost impossible. I made some tries and then finally i achieve to type in correctly.
I don't think the ideal solution is to use the buttons for all cases. Think if you have to type in the amount of ex. 645 or 4 589

But what about a regular user, not so much experienced ?

You can try yourself in example page of-course Demo example page

P.S. It doesn't seem the same issue from mobile.

Feature request: Adding support for prefix and suffix

Hey,
great lib! Would it be possible for you guys to add support for prefix and suffix?

Something like that: https://stackoverflow.com/questions/49796934/add-a-text-suffix-to-input-type-number?noredirect=1&lq=1

grafik
From Octoprint.org

I made it simply with a span rendering over the input element.

<div>
<span style="position: absolute; margin-left: 15px; margin-top: 7px; z-index: 1;"> °C </span>

<input type="number" id="Temp" data-decimals="2" value="100"min="0" max="200" step="1" />                                            
</div> 

grafik

Regards

Button wrapping

Spinner is a nice control (thanks!), but I'm having problems with the plus button (button on right hand side of the text input) wrapping to underneath the text input. Obviously that makes it look pretty screwy.

My text input is inside of a td and I have set a specific width on it in order to keep it from hogging more space than it needs to enter a 2-digit age. Looks great when my browser is maxed, but as I shrink the width, not so great.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.