There are two input boxes on the page. The first input box can only input positive integers. When the value is entered in the first input box, can the second input box immediately obtain the value of the name1 input box?
How to achieve it?
onkeypress event
Thanks to the brothers upstairs, the effect I want can be achieved as follows:
<html><body><script type="text/javascript">function tests(e){var keynumvar keycharif(window.event) // IE { keynum = e.keyCode }else if(e.which) // Netscape/Firefox/Opera { keynum = e.which }//alert(keynum);keychar = String.fromCharCode(keynum)//alert(keychar);var obj = document.getElementById("id2");obj.innerText=keychar;}</script><form>Type some text (numbers not allowed):<input type="text" name="name1" onkeypress="return tests(event)" /><input type="text" name="name2" id="id2" /></form></html>