You are here: irt.org | FAQ | JavaScript | Form | 10.1 | Q476 [ previous next ]
This is only really possible in Netscape Navigator 4 and Internet Explorer 4 with the onKeyUp event handler:
<html>
<head>
<script language="JavaScript"><!--
function copyData(from,to) { to.value = from.value; }
//--></script>
</head>
<body>
<form name="myForm">
<input type="text" name="field1"
onChange="copyData(this,document.myForm.field2)"
onKeyUp="copyData(this,document.myForm.field2)">
<input type="text" name="field2"
onChange="copyData(this,document.myForm.field1)"
onKeyUp="copyData(this,document.myForm.field1)">
</form>
</body>
</html>With any older browser you have to wait until the onChange event is triggered, when the user moves away from the text field.