📜 ⬆️ ⬇️

Convenient selection of digital values ​​in the input fields

In the fireball there is a nice feature of changing numeric values.
It lies in the fact that the field value can be increased or decreased by one by pressing the up / down arrow key.

Or for a dozen immediately using the page up / down keys.

I liked this way of changing the values ​​for fitting, and I thought
which would be nice to implement something like this for the input text fields on the pages.

The idea is this.
When you press the up / down arrow key in the text field, the digit under the cursor will be increased / decreased by one.
The script makes available for such changes all text fields.
Even if the field has the value “asdf5qwer”, then the number can be changed.
')
Those. Such a change can be made in any digit of the number.
Conveniently.

For the prototype implementation, Jquery and a fieldselection plugin for it were used (1.75 KB).
The plugin is used to get and set the cursor position.

UP: Example

The implementation is trial and does not work in all browsers, the post should aim to draw attention to this method.

Source: https://habr.com/ru/post/74959/


All Articles