P
P
pro100blich2020-08-30 06:08:11
JavaScript
pro100blich, 2020-08-30 06:08:11

block input?

Good afternoon, not very selenium can anyone help. There is a user page, when he entered information in the input and clicked save, then the input should be blocked. According to the idea, if the input is filled, then the blocking, if empty, then you can enter data.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Filimonov, 2020-09-26
@VadimFilimonov

HTML

<form>
  <input required>
  <button>Сохранить</button>
</form>

JavaScript
const form = document.querySelector('form');
const input = form.querySelector('input');

form.addEventListener('submit', (event) => {
  event.preventDefault();
  input.disabled = true;
});

https://jsfiddle.net/br2uLj6t/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question