0

Let's say I have login form with login and password. Both are the same and I want to input the value in a third text input box and update the values of the login and password as I type.

How can I do this using little JavaScript and HTML only?

Dharman
  • 26,923
  • 21
  • 73
  • 125

1 Answers1

0

You can add an event listener to the text box in which the user is typing into for a keypress event. On keypress, you can then apply the current text box value into the target textbox.

document.getElementById('txtType').addEventListener('keyup', e => {
  const copyTextInput = document.getElementById('txtCopied');
  copyTextInput.value = e.target.value;
});
<label for="txtType">Type Here</label>
<input id="txtType" />
<br />
<label for="txtCopied">Copied Text as you're typing</label>
<input id="txtCopied" />
mwilson
  • 11,285
  • 5
  • 51
  • 83