L
L
leyarthemes2019-03-14 18:40:07
JavaScript
leyarthemes, 2019-03-14 18:40:07

How to programmatically change the input value for validation?

Hello, I'm making a complex form with some non-standard fields. An example of such a field is a combo box (id="itemsInput" and id="choicesInput"). The dropdown() function works as I need it (in the example it is greatly simplified), but there are problems when validating with the validateForm() function. More specifically, .addEventListener("input", function(){ }); reacts to changing the value of the field by pressing keys, but does not react in any way to changing the field with the dropdown() function. It is very important for me that the invalid class is removed when clicking or hovering on the dropdown list item on the fly, but I do not know how to do it correctly. We need pure JS, without plugins and frameworks. https://jsfiddle.net/q2uL3k57/74/ Here is an example on jsfiddle Thanks.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew, 2019-03-14
@leyarthemes

Your validation occurs on the input event, and you need to call it. https://jsfiddle.net/c0rL2g9j/ Lines 21, 25

M
Medin K, 2019-03-14
@medin84

You can rewrite set, get for value input-a
https://codesandbox.io/s/oxyxn93n6

P
Pavel Kornilov, 2019-03-14
@KorniloFF

Well, if it's completely rude, then so - https://jsfiddle.net/Lgmc3sz1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question