N
N
NewbieL2018-02-22 02:41:14
AJAX
NewbieL, 2018-02-22 02:41:14

How to display the entered text from the field immediately?

There is a field like

<input type="text" class="uk-input uk-form-width-small" name="summa" required pattern="^[ 0-9]+$" placeholder="Сумма" maxlength="6">

and there is a span tag. <span class="uk-text"></span>
Let's say I enter the number 1000 in the field, and how can I make the number 1000 divided by 100, and immediately display the result in the span tag?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
levchak0910, 2018-02-22
@NewbieL

You can use type="number"instead of type="text", and you don't need a pattern, but you don't have to

document.querySelector(".uk-input").addEventListener("input", e => {
    document.querySelector(".uk-text").innerText = e.target.value / 100
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question